Skip to content

Commit 90df89e

Browse files
authored
Merge pull request #526 from cusae/newdeb822
Update debian source from list to deb822
2 parents f39eb79 + c87acd6 commit 90df89e

5 files changed

Lines changed: 45 additions & 31 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ See [`metadata.json`](metadata.json) for supported operating systems.
369369

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

374374
If using CentOS/RHEL and you wish to install Node.js from EPEL rather
375375
than from the NodeSource repository, you will need to ensure `puppet-epel` is

manifests/params.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
$nodejs_package_ensure = 'installed'
66
$repo_ensure = 'present'
77
$repo_pin = undef
8-
$repo_priority = 'absent'
8+
$repo_priority = $facts['os']['family'] == 'Debian' ? {
9+
true => '990',
10+
default => 'absent',
11+
}
912
$repo_proxy = 'absent'
1013
$repo_proxy_password = 'absent'
1114
$repo_proxy_username = 'absent'

manifests/repo/nodesource/apt.pp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# PRIVATE CLASS: Do not use directly.
22
class nodejs::repo::nodesource::apt {
33
$ensure = $nodejs::repo::nodesource::ensure
4-
$pin = $nodejs::repo::nodesource::pin
4+
$priority = $nodejs::repo::nodesource::priority
55
$url_suffix = $nodejs::repo::nodesource::url_suffix
66

77
include apt
88

99
if ($ensure != 'absent') {
10+
apt::keyring { 'nodesource':
11+
source => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key',
12+
filename => 'nodesource-repo.gpg.key.asc',
13+
}
14+
1015
apt::source { 'nodesource':
11-
key => {
12-
'name' => 'nodesource-repo.gpg.key.asc',
13-
'source' => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key',
14-
},
15-
location => "https://deb.nodesource.com/node_${url_suffix}",
16-
pin => $pin,
17-
release => 'nodistro',
18-
repos => 'main',
16+
source_format => 'sources',
17+
location => ["https://deb.nodesource.com/node_${url_suffix}",],
18+
keyring => '/etc/apt/keyrings/nodesource-repo.gpg.key.asc',
19+
release => ['nodistro',],
20+
repos => ['main',],
21+
types => ['deb',],
22+
require => Apt::Keyring['nodesource'],
23+
}
24+
25+
apt::pin { 'nodesource':
26+
origin => 'deb.nodesource.com',
27+
priority => $priority,
1928
}
2029

2130
Apt::Source['nodesource'] -> Package<| tag == 'nodesource_repo' |>
@@ -26,5 +35,17 @@
2635
apt::source { 'nodesource':
2736
ensure => 'absent',
2837
}
38+
# Workaround https://github.com/puppetlabs/puppetlabs-apt/issues/1245
39+
file { '/etc/apt/sources.list.d/nodesource.sources':
40+
ensure => 'absent',
41+
notify => Class['Apt::Update'],
42+
}
43+
apt::pin { 'nodesource':
44+
ensure => 'absent',
45+
}
46+
apt::keyring { 'nodesource':
47+
ensure => 'absent',
48+
filename => 'nodesource-repo.gpg.key.asc',
49+
}
2950
}
3051
}

spec/acceptance/class_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,11 @@ def nodesource_unsupported(nodejs_version)
4040

4141
include_examples 'cleanup'
4242

43-
# Debian 12 contains NodeJS 18, when we test 16 and 18, we need to force the nodesource version
44-
# as Debians versions *can* be newer
45-
repo_pin =
46-
if %w[16 18].include?(nodejs_version) && fact('os.family') == 'Debian' && %w[12 13].include?(fact('os.release.major'))
47-
'1000'
48-
else
49-
'undef'
50-
end
51-
5243
it_behaves_like 'an idempotent resource' do
5344
let(:manifest) do
5445
<<-PUPPET
5546
class { 'nodejs':
5647
repo_version => '#{nodejs_version}',
57-
repo_pin => #{repo_pin},
5848
}
5949
PUPPET
6050
end

spec/classes/nodejs_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@
8484
end
8585
end
8686

87-
context 'and repo_pin set to 10' do
87+
context 'and repo_priority set to 10' do
8888
let :params do
89-
default_params.merge!(repo_pin: '10')
89+
default_params.merge!(repo_priority: '10')
9090
end
9191

92-
it 'the repo apt::source resource should contain pin = 10' do
93-
is_expected.to contain_apt__source('nodesource').with('pin' => '10')
92+
it 'the repo apt::source resource should contain priority = 10' do
93+
is_expected.to contain_apt__pin('nodesource').with('priority' => '10')
9494
end
9595
end
9696

97-
context 'and repo_pin not set' do
97+
context 'and repo_priority not set' do
9898
let :params do
99-
default_params.merge!(repo_pin: :undef)
99+
default_params.merge!(repo_priority: :undef)
100100
end
101101

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

@@ -109,8 +109,8 @@
109109
default_params.merge!(repo_version: '9')
110110
end
111111

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

0 commit comments

Comments
 (0)