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..467a4a9be 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.major'), '8') >= 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') }