From aa0104534c886c5799469148fa7ec6fc61c4c02d Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Sun, 18 Jan 2026 17:03:05 +0100 Subject: [PATCH 01/10] use new deb822 format --- manifests/repo/nodesource/apt.pp | 40 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/manifests/repo/nodesource/apt.pp b/manifests/repo/nodesource/apt.pp index e3ba5358..c8c44eec 100644 --- a/manifests/repo/nodesource/apt.pp +++ b/manifests/repo/nodesource/apt.pp @@ -1,21 +1,31 @@ # 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 $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', + dir => '/usr/share/keyrings', + filename => 'nodesource-repo.gpg.key.asc', + } + apt::source { 'nodesource': - key => { - '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 => '/usr/share/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' |> @@ -26,5 +36,17 @@ apt::source { 'nodesource': ensure => 'absent', } + apt::pin { 'nodesource': + ensure => 'absent', + } + apt::keyring { 'nodesource': + ensure => 'absent', + dir => '/usr/share/keyrings', + filename => 'nodesource-repo.gpg.key.asc', + } + file { '/etc/apt/sources.list.d/nodesource.sources': + ensure => 'absent', + notify => Class['Apt::Update'], + } } } From 55468e51341f7d90a039964c77c4b290b3882cfd Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Sun, 18 Jan 2026 17:05:50 +0100 Subject: [PATCH 02/10] use default repo priority to 990 for debian --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 971cdbaa..1d250810 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,7 @@ $nodejs_package_ensure = 'installed' $repo_ensure = 'present' $repo_pin = undef - $repo_priority = 'absent' + $repo_priority = fact('os.family') == 'Debian' ? '990' : 'absent' $repo_proxy = 'absent' $repo_proxy_password = 'absent' $repo_proxy_username = 'absent' From afebd4c048b4c7d58d243fdc3d0b71de3ac0bcd9 Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Sun, 18 Jan 2026 17:08:12 +0100 Subject: [PATCH 03/10] use priority 990 to checks --- spec/acceptance/class_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 818f15c5..1783ca3a 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -43,10 +43,10 @@ def nodesource_unsupported(nodejs_version) # 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' + if fact('os.family') == 'Debian' + '990' else - 'undef' + 'absent' end it_behaves_like 'an idempotent resource' do From 68e7f574536ce0ab9eba4ce6fb9a0e9d6b92b28e Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Sun, 18 Jan 2026 17:22:14 +0100 Subject: [PATCH 04/10] move from pin to priority for debian --- manifests/params.pp | 5 ++++- spec/acceptance/class_spec.rb | 4 ++-- spec/classes/nodejs_spec.rb | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 1d250810..a824f945 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,10 @@ $nodejs_package_ensure = 'installed' $repo_ensure = 'present' $repo_pin = undef - $repo_priority = fact('os.family') == 'Debian' ? '990' : 'absent' + $repo_priority = $facts['os']['family'] == 'Debian' ? { + true => '990', + default => 'absent', + } $repo_proxy = 'absent' $repo_proxy_password = 'absent' $repo_proxy_username = 'absent' diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 1783ca3a..08a97930 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -42,7 +42,7 @@ def nodesource_unsupported(nodejs_version) # 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 = + repo_priority = if fact('os.family') == 'Debian' '990' else @@ -54,7 +54,7 @@ def nodesource_unsupported(nodejs_version) <<-PUPPET class { 'nodejs': repo_version => '#{nodejs_version}', - repo_pin => #{repo_pin}, + repo_priority => #{repo_priority}, } PUPPET end diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index f63b30db..c3104035 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -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 @@ -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 From 01633e77000b2de6fe4d2fd3f0946425a106d5c9 Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Sun, 18 Jan 2026 17:42:31 +0100 Subject: [PATCH 05/10] add a note for the puppetlabs-apt bug --- manifests/repo/nodesource/apt.pp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manifests/repo/nodesource/apt.pp b/manifests/repo/nodesource/apt.pp index c8c44eec..3a38380d 100644 --- a/manifests/repo/nodesource/apt.pp +++ b/manifests/repo/nodesource/apt.pp @@ -36,6 +36,11 @@ 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', } @@ -44,9 +49,5 @@ dir => '/usr/share/keyrings', filename => 'nodesource-repo.gpg.key.asc', } - file { '/etc/apt/sources.list.d/nodesource.sources': - ensure => 'absent', - notify => Class['Apt::Update'], - } } } From b0327ea070d8e22e9600c28e1e5e52abb3fc4949 Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Mon, 19 Jan 2026 22:59:06 +0100 Subject: [PATCH 06/10] drop repo_priority modifications from acceptance, base it on the default from params.pp --- spec/acceptance/class_spec.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 08a97930..89f3a2d8 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -40,21 +40,11 @@ def nodesource_unsupported(nodejs_version) 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_priority = - if fact('os.family') == 'Debian' - '990' - else - 'absent' - end - it_behaves_like 'an idempotent resource' do let(:manifest) do <<-PUPPET class { 'nodejs': repo_version => '#{nodejs_version}', - repo_priority => #{repo_priority}, } PUPPET end From 0cec4046aa376de29b32e1c985bdee538ffb206b Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Thu, 5 Feb 2026 10:42:24 +0100 Subject: [PATCH 07/10] change keyring directory --- manifests/repo/nodesource/apt.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/repo/nodesource/apt.pp b/manifests/repo/nodesource/apt.pp index 3a38380d..898a52a6 100644 --- a/manifests/repo/nodesource/apt.pp +++ b/manifests/repo/nodesource/apt.pp @@ -9,14 +9,14 @@ if ($ensure != 'absent') { apt::keyring { 'nodesource': source => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key', - dir => '/usr/share/keyrings', + dir => '/etc/apt/keyring', filename => 'nodesource-repo.gpg.key.asc', } apt::source { 'nodesource': source_format => 'sources', location => ["https://deb.nodesource.com/node_${url_suffix}",], - keyring => '/usr/share/keyrings/nodesource-repo.gpg.key.asc', + keyring => '/etc/apt/keyring/nodesource-repo.gpg.key.asc', release => ['nodistro',], repos => ['main',], types => ['deb',], @@ -46,7 +46,7 @@ } apt::keyring { 'nodesource': ensure => 'absent', - dir => '/usr/share/keyrings', + dir => '/etc/apt/keyring', filename => 'nodesource-repo.gpg.key.asc', } } From 54671a279dc128e5cc848757c4825dbbad221dc2 Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Thu, 5 Feb 2026 13:38:18 +0100 Subject: [PATCH 08/10] as @evgeni pointed out, /etc/apt/keyrings is the default, don't specify it --- manifests/repo/nodesource/apt.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/repo/nodesource/apt.pp b/manifests/repo/nodesource/apt.pp index 898a52a6..d7f8ca71 100644 --- a/manifests/repo/nodesource/apt.pp +++ b/manifests/repo/nodesource/apt.pp @@ -9,7 +9,6 @@ if ($ensure != 'absent') { apt::keyring { 'nodesource': source => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key', - dir => '/etc/apt/keyring', filename => 'nodesource-repo.gpg.key.asc', } @@ -46,7 +45,6 @@ } apt::keyring { 'nodesource': ensure => 'absent', - dir => '/etc/apt/keyring', filename => 'nodesource-repo.gpg.key.asc', } } From e4d47637f3b657999600e362d6be8cce351162c8 Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Thu, 5 Feb 2026 14:03:21 +0100 Subject: [PATCH 09/10] wrong dir, missed a s --- manifests/repo/nodesource/apt.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/repo/nodesource/apt.pp b/manifests/repo/nodesource/apt.pp index d7f8ca71..d4998d7d 100644 --- a/manifests/repo/nodesource/apt.pp +++ b/manifests/repo/nodesource/apt.pp @@ -15,7 +15,7 @@ apt::source { 'nodesource': source_format => 'sources', location => ["https://deb.nodesource.com/node_${url_suffix}",], - keyring => '/etc/apt/keyring/nodesource-repo.gpg.key.asc', + keyring => '/etc/apt/keyrings/nodesource-repo.gpg.key.asc', release => ['nodistro',], repos => ['main',], types => ['deb',], From c87acd6e81b63d6a36e1490664f722ea9d27f7cd Mon Sep 17 00:00:00 2001 From: Arnaud Launay Date: Fri, 20 Feb 2026 14:33:05 +0100 Subject: [PATCH 10/10] add note that deb822 requires puppetlabs-apt >= 10.0.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12c78321..b23f643d 100644 --- a/README.md +++ b/README.md @@ -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