Skip to content
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ See [`metadata.json`](metadata.json) for supported operating systems.

This modules uses `puppetlabs-apt` for the management of the NodeSource
repository. If using an operating system of the Debian-based family, you will
need to ensure that `puppetlabs-apt` version 4.4.0 or above is installed.
need to ensure that `puppetlabs-apt` version 10.0.0 or above is installed.

If using CentOS/RHEL and you wish to install Node.js from EPEL rather
than from the NodeSource repository, you will need to ensure `puppet-epel` is
Expand Down
5 changes: 4 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
$nodejs_package_ensure = 'installed'
$repo_ensure = 'present'
$repo_pin = undef
$repo_priority = 'absent'
$repo_priority = $facts['os']['family'] == 'Debian' ? {
true => '990',
default => 'absent',
}
$repo_proxy = 'absent'
$repo_proxy_password = 'absent'
$repo_proxy_username = 'absent'
Expand Down
39 changes: 30 additions & 9 deletions manifests/repo/nodesource/apt.pp
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
# PRIVATE CLASS: Do not use directly.
class nodejs::repo::nodesource::apt {
$ensure = $nodejs::repo::nodesource::ensure
$pin = $nodejs::repo::nodesource::pin
$priority = $nodejs::repo::nodesource::priority
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO not a breaking change because it's a private class and both variables already exists in nodejs::repo::nodesource.

$url_suffix = $nodejs::repo::nodesource::url_suffix

include apt

if ($ensure != 'absent') {
apt::keyring { 'nodesource':
source => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key',
filename => 'nodesource-repo.gpg.key.asc',
}

apt::source { 'nodesource':
key => {
Comment thread
alaunay marked this conversation as resolved.
'name' => 'nodesource-repo.gpg.key.asc',
'source' => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key',
},
location => "https://deb.nodesource.com/node_${url_suffix}",
pin => $pin,
release => 'nodistro',
repos => 'main',
source_format => 'sources',
location => ["https://deb.nodesource.com/node_${url_suffix}",],
keyring => '/etc/apt/keyrings/nodesource-repo.gpg.key.asc',
release => ['nodistro',],
repos => ['main',],
types => ['deb',],
require => Apt::Keyring['nodesource'],
}

apt::pin { 'nodesource':
origin => 'deb.nodesource.com',
priority => $priority,
}

Apt::Source['nodesource'] -> Package<| tag == 'nodesource_repo' |>
Expand All @@ -26,5 +35,17 @@
apt::source { 'nodesource':
ensure => 'absent',
}
# Workaround https://github.com/puppetlabs/puppetlabs-apt/issues/1245
file { '/etc/apt/sources.list.d/nodesource.sources':
ensure => 'absent',
notify => Class['Apt::Update'],
}
apt::pin { 'nodesource':
ensure => 'absent',
}
apt::keyring { 'nodesource':
ensure => 'absent',
filename => 'nodesource-repo.gpg.key.asc',
}
}
}
10 changes: 0 additions & 10 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,28 @@

include_examples 'cleanup'

# Debian 12 contains NodeJS 18, when we test 16 and 18, we need to force the nodesource version
# as Debians versions *can* be newer
repo_pin =
if %w[16 18].include?(nodejs_version) && fact('os.family') == 'Debian' && %w[12 13].include?(fact('os.release.major'))
'1000'
else
'undef'
end

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'nodejs':
repo_version => '#{nodejs_version}',
repo_pin => #{repo_pin},
}
PUPPET
end
end

describe package('nodejs') do
it { is_expected.to be_installed }

Check warning on line 54 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" Skipped: NodeJS 16 is not supported on EL9

Check warning on line 54 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" Skipped: NodeJS 16 is not supported on EL9

Check warning on line 54 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" Skipped: NodeJS 16 is not supported on EL9

Check warning on line 54 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" Skipped: NodeJS 16 is not supported on EL9

it 'comes from the expected source' do

Check warning on line 56 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" comes from the expected source Skipped: NodeJS 16 is not supported on EL9

Check warning on line 56 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" comes from the expected source Skipped: NodeJS 16 is not supported on EL9

Check warning on line 56 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" comes from the expected source Skipped: NodeJS 16 is not supported on EL9

Check warning on line 56 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Package "nodejs" comes from the expected source Skipped: NodeJS 16 is not supported on EL9
pkg_output = shell(pkg_cmd)
expect(pkg_output.stdout).to match 'nodesource'
end
end

describe command('node --version') do
its(:exit_status) { is_expected.to eq 0 }

Check warning on line 63 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" exit_status Skipped: NodeJS 16 is not supported on EL9

Check warning on line 63 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" exit_status Skipped: NodeJS 16 is not supported on EL9

Check warning on line 63 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" exit_status Skipped: NodeJS 16 is not supported on EL9

Check warning on line 63 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" exit_status Skipped: NodeJS 16 is not supported on EL9
its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) }

Check warning on line 64 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" stdout Skipped: NodeJS 16 is not supported on EL9

Check warning on line 64 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" stdout Skipped: NodeJS 16 is not supported on EL9

Check warning on line 64 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" stdout Skipped: NodeJS 16 is not supported on EL9

Check warning on line 64 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 16

nodejs explicitly using version 16 from nodesource Command "node --version" stdout Skipped: NodeJS 16 is not supported on EL9
end
end

Expand Down Expand Up @@ -105,7 +95,7 @@
nodejs-devel
].each do |pkg|
describe package(pkg) do
it do

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 16

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 16

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 16

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 20

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 24

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 22

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 16

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - AlmaLinux 9 - NodeJS 18

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 20

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 18

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 20

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 24

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 18

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - Rocky 9 - NodeJS 22

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 22

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - CentOS 9 - NodeJS 24

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 20

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 24

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 18

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 98 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / OpenVox 8 - OracleLinux 9 - NodeJS 22

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed
pending('nodejs-devel and nodejs not installable together on EL9') if fact('os.release.major') == '9' && pkg == 'nodejs-devel'
is_expected.to be_installed
end
Expand Down
20 changes: 10 additions & 10 deletions spec/classes/nodejs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@
end
end

context 'and repo_pin set to 10' do
context 'and repo_priority set to 10' do
let :params do
default_params.merge!(repo_pin: '10')
default_params.merge!(repo_priority: '10')
end

it 'the repo apt::source resource should contain pin = 10' do
is_expected.to contain_apt__source('nodesource').with('pin' => '10')
it 'the repo apt::source resource should contain priority = 10' do
is_expected.to contain_apt__pin('nodesource').with('priority' => '10')
end
end

context 'and repo_pin not set' do
context 'and repo_priority not set' do
let :params do
default_params.merge!(repo_pin: :undef)
default_params.merge!(repo_priority: :undef)
end

it 'the repo apt::source resource should contain pin = undef' do
is_expected.to contain_apt__source('nodesource').with('pin' => nil)
it 'the repo apt::source resource should contain priority = 990' do
is_expected.to contain_apt__pin('nodesource').with('priority' => 990)
end
end

Expand All @@ -109,8 +109,8 @@
default_params.merge!(repo_version: '9')
end

it 'the repo apt::source resource should contain location = https://deb.nodesource.com/node_9.x' do
is_expected.to contain_apt__source('nodesource').with('location' => 'https://deb.nodesource.com/node_9.x')
it 'the repo apt::source resource should contain location = [https://deb.nodesource.com/node_9.x]' do
is_expected.to contain_apt__source('nodesource').with('location' => ['https://deb.nodesource.com/node_9.x'])
end
end

Expand Down
Loading