From c543c11c007dcde31f783c1cbd277b2f1eedb0e9 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Sun, 29 Oct 2023 13:00:18 +0100 Subject: [PATCH] add dnfmodule repo implementation --- manifests/repo/dnfmodule.pp | 23 ++++++++++++++++++++++ spec/acceptance/class_spec.rb | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 manifests/repo/dnfmodule.pp diff --git a/manifests/repo/dnfmodule.pp b/manifests/repo/dnfmodule.pp new file mode 100644 index 00000000..e25cd124 --- /dev/null +++ b/manifests/repo/dnfmodule.pp @@ -0,0 +1,23 @@ +# @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, + 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 }