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 support for AppStream package installation #1459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -331,6 +332,14 @@ Can be used to define default values for the parameter `nginx_snippets`.

Default value: `{}`

##### <a name="-nginx--dnfmodule"></a>`dnfmodule`

Data type: `Optional[String[1]]`

Specifies which dnf AppStream stream to enable for nginx package.

Default value: `undef`

##### <a name="-nginx--client_body_temp_path"></a>`client_body_temp_path`

Data type: `Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]]`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
kenyon marked this conversation as resolved.
Show resolved Hide resolved
### END Package Configuration ###

### START Service Configuation ###
Expand Down
11 changes: 11 additions & 0 deletions manifests/package/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down