Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dnfmodule repo implementation #488

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions manifests/repo/dnfmodule.pp
Original file line number Diff line number Diff line change
@@ -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':
evgeni marked this conversation as resolved.
Show resolved Hide resolved
ensure => $ensure,
name => $module,
enable_only => true,
ekohl marked this conversation as resolved.
Show resolved Hide resolved
provider => 'dnfmodule',
}
}
43 changes: 43 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
nodejs-devel
].each do |pkg|
describe package(pkg) do
it do

Check warning on line 60 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 - CentOS 9

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 60 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 - CentOS 9

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 60 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 - OracleLinux 9

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed

Check warning on line 60 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 - OracleLinux 9

nodejs RedHat with repo_class => epel Package "nodejs-devel" is expected to be installed Failure/Error: is_expected.to be_installed expected Package "nodejs-devel" to be installed
pending('nodejs-devel and nodejs not installable together on EL9') if fact('os.release.major') == '9' && pkg == 'nodejs-devel'
is_expected.to be_installed
end
Expand All @@ -65,6 +65,49 @@
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
nodejs_version = '18'

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 => '#{nodejs_version}',
}
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
evgeni marked this conversation as resolved.
Show resolved Hide resolved
pkg_output = shell(pkg_cmd)
expect(pkg_output.stdout).to match 'appstream'
end
end
end

describe command('node --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) }
end
end

context 'Debian distribution packages', if: fact('os.family') == 'Debian' do
before(:context) { purge_node }

Expand Down