diff --git a/manifests/repo/dnfmodule.pp b/manifests/repo/dnfmodule.pp new file mode 100644 index 00000000..3026aad6 --- /dev/null +++ b/manifests/repo/dnfmodule.pp @@ -0,0 +1,24 @@ +# @summary Manage the DNF module +# +# On EL8+ DNF can manage modules. +# This is a method of providing multiple versions on the same OS. +# Only one DNF module stream can be active at the same time. +# +# @param ensure +# Value of ensure parameter for nodejs dnf module package +# +# @param module +# Name of the nodejs dnf package +# +# @api private +class nodejs::repo::dnfmodule ( + String[1] $ensure = $nodejs::repo_version, + String[1] $module = 'nodejs', +) { + package { 'nodejs dnf module': + ensure => $ensure, + name => $module, + enable_only => true, + provider => 'dnfmodule', + } +} diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 9e26e738..abac6a0d 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -65,6 +65,42 @@ class { 'nodejs': end end + context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')) do + include_examples 'cleanup' + + # Node 20 is only available in Stream yet, not in a released EL + # So we're testing 18 here + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, + repo_class => 'nodejs::repo::dnfmodule', + repo_version => '18', + } + PUPPET + end + end + + %w[ + npm + nodejs + nodejs-devel + ].each do |pkg| + describe package(pkg) do + it do + is_expected.to be_installed + end + + it 'comes from the expected source' do + pkg_output = shell(pkg_cmd) + expect(pkg_output.stdout).to match 'appstream' + end + end + end + end + context 'Debian distribution packages', if: fact('os.family') == 'Debian' do before(:context) { purge_node }