From dd6797d55a24845d28b7c3e3cb2e2d73b7333d9c Mon Sep 17 00:00:00 2001 From: Henrik Hansson Date: Tue, 20 Jul 2021 14:24:12 +0200 Subject: [PATCH] Add support for AppStream package installation --- manifests/init.pp | 1 + manifests/package/redhat.pp | 9 +++++++++ spec/classes/nginx_spec.rb | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 11612a055..02aea5095 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -196,6 +196,7 @@ $passenger_package_ensure = 'present', String[1] $passenger_package_name = $nginx::params::passenger_package_name, Optional[Stdlib::HTTPUrl] $repo_source = undef, + Optional[Float] $dnfmodule = undef, ### END Package Configuration ### ### START Service Configuation ### diff --git a/manifests/package/redhat.pp b/manifests/package/redhat.pp index a49870a41..b35c78f8d 100644 --- a/manifests/package/redhat.pp +++ b/manifests/package/redhat.pp @@ -9,6 +9,7 @@ $passenger_package_name = $nginx::passenger_package_name $manage_repo = $nginx::manage_repo $purge_passenger_repo = $nginx::purge_passenger_repo + $dnfmodule = $nginx::dnfmodule #Install the CentOS-specific packages on that OS, otherwise assume it's a RHEL #clone and provide the Red Hat-specific package. This comes into play when not @@ -94,6 +95,14 @@ } } + if $dnfmodule and ($facts['os']['name'] in ['RedHat', 'CentOS', 'VirtuozzoLinux']) and ($facts['os']['release']['major'] in ['8']) { + package { "nginx:${dnfmodule}": + ensure => present, + before => Package['nginx'], + provider => dnfmodule, + } + } + package { 'nginx': ensure => $package_ensure, name => $package_name, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 7efe29992..04af5a858 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -139,6 +139,24 @@ end end + context 'dnfmodule => 1.18' do + let(:params) { { dnfmodule: 1.18 } } + + if %w[8].include?(facts.dig(:os, 'release', 'major')) + it { is_expected.to contain_package('nginx') } + it do + is_expected.to contain_package('nginx:1.18').with( + 'ensure' => 'present', + 'before' => Package['nginx'], + 'provider' => 'dnfmodule' + ) + end + else + it { is_expected.to contain_package('nginx') } + it { is_expected.not_to contain_package('nginx:1.18') } + end + end + when 'Debian' context 'using defaults' do it { is_expected.to contain_package('nginx') }