From ba1e2dbe3d3eb3a3d5813c7b566942905f1809d3 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 | 24 ++++++++++++++++++++++++ spec/acceptance/class_spec.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 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..083d1d98 --- /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 redis dns 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..a7229829 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -65,6 +65,34 @@ class { 'nodejs': end end + context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && fact('os.release.major') in ['8', '9'] do + include_examples 'cleanup' + + 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', + } + PUPPET + end + end + + %w[ + npm + nodejs + nodejs-devel + ].each do |pkg| + describe package(pkg) do + it do + is_expected.to be_installed + end + end + end + end + context 'Debian distribution packages', if: fact('os.family') == 'Debian' do before(:context) { purge_node }