Skip to content

Commit

Permalink
Add enable_centos_release parameter
Browse files Browse the repository at this point in the history
Add an `enable_centos_release` parameter, defaulting to `false`, except
on CentOS, where it defaults to `true. If enabled on any OS in the
RedHat family when `repos_ensure` is also disabled, it controls adding
the `centos-release-rabbitmq` package (currently
`centos-release-rabbitmq-38`)

Fixes voxpupuli#1033
Closes voxpupuli#1032
  • Loading branch information
wyardley committed Dec 11, 2024
1 parent 82010fc commit a1538d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ The following parameters are available in the `rabbitmq` class:
* [`default_user`](#-rabbitmq--default_user)
* [`default_pass`](#-rabbitmq--default_pass)
* [`delete_guest_user`](#-rabbitmq--delete_guest_user)
* [`enable_centos_release`](#-rabbitmq--enable_centos_release)
* [`env_config`](#-rabbitmq--env_config)
* [`env_config_path`](#-rabbitmq--env_config_path)
* [`environment_variables`](#-rabbitmq--environment_variables)
Expand Down Expand Up @@ -508,6 +509,15 @@ Controls whether default guest user is deleted.

Default value: `false`

##### <a name="-rabbitmq--enable_centos_release"></a>`enable_centos_release`

Data type: `Boolean`

Enable the `centos-release-rabbitmq-38` if set to `true` and if the OS is in the
RedHat family and `repos_ensure` is `false`. Defaults to true on CentOS.

Default value: `false`

##### <a name="-rabbitmq--env_config"></a>`env_config`

Data type: `String`
Expand Down
1 change: 1 addition & 0 deletions data/os/CentOS.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rabbitmq::enable_centos_release: true
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
# Password to set for the `default_user` in rabbitmq.config.
# @param delete_guest_user
# Controls whether default guest user is deleted.
# @param enable_centos_release
# Enable the `centos-release-rabbitmq-38` if set to `true` and if the OS is in the
# RedHat family and `repos_ensure` is `false`. Defaults to true on CentOS.
# @param env_config
# The template file to use for rabbitmq_env.config.
# @param env_config_path
Expand Down Expand Up @@ -369,6 +372,7 @@
String $default_user = 'guest',
String $default_pass = 'guest',
Boolean $delete_guest_user = false,
Boolean $enable_centos_release = false,
String $env_config = 'rabbitmq/rabbitmq-env.conf.epp',
Stdlib::Absolutepath $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf',
Optional[String] $erlang_cookie = undef,
Expand Down Expand Up @@ -513,7 +517,7 @@
default: {
}
}
} elsif $facts['os']['family'] == 'RedHat' {
} elsif $facts['os']['family'] == 'RedHat' and $enable_centos_release {
package { 'centos-release-rabbitmq-38':
ensure => 'present',
}
Expand Down
9 changes: 8 additions & 1 deletion spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
it { is_expected.not_to contain_class('rabbitmq::repo::rhel') }
it { is_expected.not_to contain_yumrepo('rabbitmq') }

it { is_expected.to contain_package('centos-release-rabbitmq-38') } if os_facts['os']['family'] == 'RedHat'
it { is_expected.to contain_package('centos-release-rabbitmq-38') } if os_facts['os']['name'] == 'CentOS'
it { is_expected.not_to contain_package('centos-release-rabbitmq-38') } if os_facts['os']['name'] == 'RedHat'
end

context 'with service_restart => false' do
Expand All @@ -48,6 +49,12 @@
it { is_expected.not_to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
end

context 'with enable_centos_release set to false' do
let(:params) { { enable_centos_release: false } }

it { is_expected.not_to contain_package('centos-release-rabbitmq-38') } if os_facts['os']['family'] == 'RedHat'
end

context 'with repos_ensure => true' do
let(:params) { { repos_ensure: true } }

Expand Down

0 comments on commit a1538d4

Please sign in to comment.