Skip to content

Commit bf1c3ac

Browse files
authored
Merge pull request #488 from voxpupuli/dnfmodule
add dnfmodule repo implementation
2 parents 7ce8e64 + 9df597b commit bf1c3ac

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

manifests/repo/dnfmodule.pp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# @summary Manage the DNF module
2+
#
3+
# On EL8+ DNF can manage modules.
4+
# This is a method of providing multiple versions on the same OS.
5+
# Only one DNF module stream can be active at the same time.
6+
#
7+
# @param ensure
8+
# Value of ensure parameter for nodejs dnf module package
9+
#
10+
# @param module
11+
# Name of the nodejs dnf package
12+
#
13+
# @api private
14+
class nodejs::repo::dnfmodule (
15+
String[1] $ensure = $nodejs::repo_version,
16+
String[1] $module = 'nodejs',
17+
) {
18+
package { 'nodejs dnf module':
19+
ensure => $ensure,
20+
name => $module,
21+
enable_only => true,
22+
provider => 'dnfmodule',
23+
}
24+
}

spec/acceptance/class_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,49 @@ class { 'nodejs':
6565
end
6666
end
6767

68+
context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')) do
69+
include_examples 'cleanup'
70+
71+
# Node 20 is only available in Stream yet, not in a released EL
72+
# So we're testing 18 here
73+
nodejs_version = '18'
74+
75+
it_behaves_like 'an idempotent resource' do
76+
let(:manifest) do
77+
<<-PUPPET
78+
class { 'nodejs':
79+
nodejs_dev_package_ensure => installed,
80+
npm_package_ensure => installed,
81+
repo_class => 'nodejs::repo::dnfmodule',
82+
repo_version => '#{nodejs_version}',
83+
}
84+
PUPPET
85+
end
86+
end
87+
88+
%w[
89+
npm
90+
nodejs
91+
nodejs-devel
92+
].each do |pkg|
93+
describe package(pkg) do
94+
it do
95+
is_expected.to be_installed
96+
end
97+
98+
it 'comes from the expected source' do
99+
pkg_output = shell(pkg_cmd)
100+
expect(pkg_output.stdout).to match 'appstream'
101+
end
102+
end
103+
end
104+
105+
describe command('node --version') do
106+
its(:exit_status) { is_expected.to eq 0 }
107+
its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) }
108+
end
109+
end
110+
68111
context 'Debian distribution packages', if: fact('os.family') == 'Debian' do
69112
before(:context) { purge_node }
70113

0 commit comments

Comments
 (0)