From f29f8669fa81731dce975a5f5fe7a1743db6d4a3 Mon Sep 17 00:00:00 2001 From: Henrik Hansson Date: Tue, 20 Jul 2021 14:24:12 +0200 Subject: [PATCH 1/2] Add support for AppStream package installation --- REFERENCE.md | 9 +++++++++ manifests/init.pp | 4 ++++ manifests/package/redhat.pp | 11 +++++++++++ spec/classes/nginx_spec.rb | 24 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index 8188c1057..054cd8e48 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -82,6 +82,7 @@ The following parameters are available in the `nginx` class: * [`reset_timedout_connection`](#-nginx--reset_timedout_connection) * [`nginx_snippets`](#-nginx--nginx_snippets) * [`nginx_snippets_defaults`](#-nginx--nginx_snippets_defaults) +* [`dnfmodule`](#-nginx--dnfmodule) * [`client_body_temp_path`](#-nginx--client_body_temp_path) * [`confd_only`](#-nginx--confd_only) * [`confd_purge`](#-nginx--confd_purge) @@ -331,6 +332,14 @@ Can be used to define default values for the parameter `nginx_snippets`. Default value: `{}` +##### `dnfmodule` + +Data type: `Optional[String[1]]` + +Specifies which dnf AppStream stream to enable for nginx package. + +Default value: `undef` + ##### `client_body_temp_path` Data type: `Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]]` diff --git a/manifests/init.pp b/manifests/init.pp index f78afd2e5..a47258849 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -44,6 +44,9 @@ # @param nginx_snippets_defaults # Can be used to define default values for the parameter `nginx_snippets`. # +# @param dnfmodule +# Specifies which dnf AppStream stream to enable for nginx package. +# class nginx ( ### START Nginx Configuration ### Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]] $client_body_temp_path = undef, @@ -209,6 +212,7 @@ String $passenger_package_ensure = installed, String[1] $passenger_package_name = $nginx::params::passenger_package_name, Optional[Stdlib::HTTPUrl] $repo_source = undef, + Optional[String[1]] $dnfmodule = undef, ### END Package Configuration ### ### START Service Configuation ### diff --git a/manifests/package/redhat.pp b/manifests/package/redhat.pp index f6e221109..989ae0c16 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 @@ -103,6 +104,16 @@ } } + if $dnfmodule and fact('os.family') == 'RedHat' and versioncmp(fact('os.release.full'), '8.0') >= 0 { + package { "nginx:${dnfmodule}": + ensure => $dnfmodule, + name => 'nginx', + provider => 'dnfmodule', + before => Package['nginx'], + enable_only => true, + } + } + package { 'nginx': ensure => $package_ensure, name => $package_name, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index ae70a3f08..7129da0e7 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -151,6 +151,30 @@ end end + context 'dnfmodule => 1.18' do + let(:params) { { dnfmodule: '1.18' } } + + it do + is_expected.to contain_package('nginx') + end + + if %w[8].include?(facts.dig(:os, 'release', 'major')) + it do + is_expected.to contain_package('nginx:1.18').with( + 'ensure' => '1.18', + 'name' => 'nginx', + 'before' => 'Package[nginx]', + 'provider' => 'dnfmodule', + 'enable_only' => true + ) + end + else + it do + is_expected.not_to contain_package('nginx:1.18') + end + end + end + when 'Debian' context 'using defaults' do it { is_expected.to contain_package('nginx') } From 3aad2f23842f1dec0968a378b31026a5617036d8 Mon Sep 17 00:00:00 2001 From: Henrik Hansson Date: Tue, 8 Mar 2022 13:57:24 +0100 Subject: [PATCH 2/2] Use os.release.major instead of os.release.full Co-authored-by: Ewoud Kohl van Wijngaarden --- manifests/package/redhat.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/package/redhat.pp b/manifests/package/redhat.pp index 989ae0c16..467a4a9be 100644 --- a/manifests/package/redhat.pp +++ b/manifests/package/redhat.pp @@ -104,7 +104,7 @@ } } - if $dnfmodule and fact('os.family') == 'RedHat' and versioncmp(fact('os.release.full'), '8.0') >= 0 { + if $dnfmodule and fact('os.family') == 'RedHat' and versioncmp(fact('os.release.major'), '8') >= 0 { package { "nginx:${dnfmodule}": ensure => $dnfmodule, name => 'nginx',