diff --git a/REFERENCE.md b/REFERENCE.md index ba3c055f5..d9f954950 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -778,11 +778,11 @@ Default value: `'python'` Data type: `Boolean` Ensure that a repo with the official (and newer) RabbitMQ package is configured, along with its signing key. -Defaults to false (use system packages). This does not ensure that soft dependencies (like EPEL on RHEL systems) are present. +Defaults to true. This does not ensure that soft dependencies (like EPEL on RHEL systems) are present. It also does not solve the erlang dependency. See https://www.rabbitmq.com/which-erlang.html for a good breakdown of the different ways of handling the erlang deps. See also https://github.com/voxpupuli/puppet-rabbitmq/issues/788 -Default value: `false` +Default value: `true` ##### `service_ensure` diff --git a/data/common.yaml b/data/common.yaml index c25d117d6..20bd99ee7 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -31,7 +31,6 @@ rabbitmq::repo_gpg_key: ~ rabbitmq::package_name: 'rabbitmq' rabbitmq::package_source: ~ rabbitmq::package_provider: ~ -rabbitmq::repos_ensure: false rabbitmq::manage_python: true rabbitmq::python_package: 'python' rabbitmq::rabbitmq_user: 'rabbitmq' diff --git a/data/family/RedHat.yaml b/data/family/RedHat.yaml index 347c23261..ed86e4d54 100644 --- a/data/family/RedHat.yaml +++ b/data/family/RedHat.yaml @@ -1,5 +1,6 @@ --- +rabbitmq::python_package: 'python3' rabbitmq::package_name: 'rabbitmq-server' rabbitmq::service_name: 'rabbitmq-server' rabbitmq::package_gpg_key: 'https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc' -rabbitmq::repo_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey' \ No newline at end of file +rabbitmq::repo_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey' diff --git a/examples/full.pp b/examples/full.pp index 9e28ed7ca..65a9b3a60 100644 --- a/examples/full.pp +++ b/examples/full.pp @@ -1,6 +1,5 @@ class { 'rabbitmq': delete_guest_user => true, - repos_ensure => true, package_apt_pin => 900, } diff --git a/manifests/init.pp b/manifests/init.pp index 741acbb17..9ed0a1809 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -238,7 +238,7 @@ # Name of the package required by rabbitmqadmin. # @param repos_ensure # Ensure that a repo with the official (and newer) RabbitMQ package is configured, along with its signing key. -# Defaults to false (use system packages). This does not ensure that soft dependencies (like EPEL on RHEL systems) are present. +# Defaults to true. This does not ensure that soft dependencies (like EPEL on RHEL systems) are present. # It also does not solve the erlang dependency. See https://www.rabbitmq.com/which-erlang.html for a good breakdown of the # different ways of handling the erlang deps. See also https://github.com/voxpupuli/puppet-rabbitmq/issues/788 # @param service_ensure @@ -377,7 +377,7 @@ Variant[String, Array] $package_name = 'rabbitmq', Optional[String] $package_source = undef, Optional[String] $package_provider = undef, - Boolean $repos_ensure = false, + Boolean $repos_ensure = true, Boolean $manage_python = true, String $python_package = 'python', String $rabbitmq_user = 'rabbitmq', diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 009b35b08..147775a42 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -15,11 +15,8 @@ context 'default class inclusion' do let(:pp) do <<-EOS + class { 'erlang': } -> class { 'rabbitmq': } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS end @@ -51,13 +48,10 @@ class { 'erlang': epel_enable => true} context 'disable and stop service' do let(:pp) do <<-EOS + class { 'erlang': } -> class { 'rabbitmq': service_ensure => 'stopped', } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS end @@ -72,22 +66,16 @@ class { 'erlang': epel_enable => true} context 'service is unmanaged' do it 'runs successfully' do pp_pre = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': service_manage => false, service_ensure => 'stopped', } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp_pre, catch_failures: true) diff --git a/spec/acceptance/clustering_spec.rb b/spec/acceptance/clustering_spec.rb index fa689cf42..16e16f76e 100644 --- a/spec/acceptance/clustering_spec.rb +++ b/spec/acceptance/clustering_spec.rb @@ -6,6 +6,7 @@ context 'rabbitmq::wipe_db_on_cookie_change => false' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': cluster => { 'name' => 'rabbit_cluster', 'init_node' => $facts['fqdn'] }, config_cluster => true, @@ -14,10 +15,6 @@ class { 'rabbitmq': erlang_cookie => 'TESTCOOKIE', wipe_db_on_cookie_change => false, } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp, expect_failures: true) @@ -31,6 +28,7 @@ class { 'erlang': epel_enable => true} context 'rabbitmq::wipe_db_on_cookie_change => true' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': cluster => { 'name' => 'rabbit_cluster', 'init_node' => $facts['fqdn'] }, config_cluster => true, @@ -39,10 +37,6 @@ class { 'rabbitmq': erlang_cookie => 'TESTCOOKIE', wipe_db_on_cookie_change => true, } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp, catch_failures: true) @@ -76,6 +70,7 @@ class { 'erlang': epel_enable => true} context 'rabbitmq::cluster[:local_node] = foobar' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': cluster => { 'name' => 'rabbit_cluster', 'init_node' => 'foobar', 'local_node' => 'foobar' }, config_cluster => true, @@ -84,10 +79,6 @@ class { 'rabbitmq': environment_variables => { 'NODENAME' => 'rabbit@foobar' }, erlang_cookie => 'TESTCOOKIE', } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp, expect_failures: true) diff --git a/spec/acceptance/delete_guest_user_spec.rb b/spec/acceptance/delete_guest_user_spec.rb index 15bdff93f..2d5005a5b 100644 --- a/spec/acceptance/delete_guest_user_spec.rb +++ b/spec/acceptance/delete_guest_user_spec.rb @@ -6,14 +6,11 @@ context 'delete_guest_user' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': port => 5672, delete_guest_user => true, } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp, catch_failures: true) diff --git a/spec/acceptance/parameter_spec.rb b/spec/acceptance/parameter_spec.rb index 38ed4b53a..8e4a6a5a1 100644 --- a/spec/acceptance/parameter_spec.rb +++ b/spec/acceptance/parameter_spec.rb @@ -6,10 +6,7 @@ context 'create parameter resource' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, diff --git a/spec/acceptance/policy_spec.rb b/spec/acceptance/policy_spec.rb index 1cd126344..5edcab199 100644 --- a/spec/acceptance/policy_spec.rb +++ b/spec/acceptance/policy_spec.rb @@ -6,10 +6,7 @@ context 'create policy resource' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, diff --git a/spec/acceptance/queue_spec.rb b/spec/acceptance/queue_spec.rb index 2934796e9..266520cdc 100644 --- a/spec/acceptance/queue_spec.rb +++ b/spec/acceptance/queue_spec.rb @@ -6,10 +6,7 @@ context 'create binding and queue resources when using default management port' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, @@ -80,10 +77,7 @@ class { 'rabbitmq': context 'create multiple bindings when same source / destination / vhost but different routing keys' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, @@ -168,10 +162,7 @@ class { 'rabbitmq': context 'create binding and queue resources when using a non-default management port' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, diff --git a/spec/acceptance/rabbitmqadmin_spec.rb b/spec/acceptance/rabbitmqadmin_spec.rb index fa127f1b4..bb72ecea0 100644 --- a/spec/acceptance/rabbitmqadmin_spec.rb +++ b/spec/acceptance/rabbitmqadmin_spec.rb @@ -6,14 +6,11 @@ context 'downloads the cli tools' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': admin_enable => true, service_manage => true, } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS apply_manifest(pp, catch_failures: true) @@ -27,14 +24,11 @@ class { 'erlang': epel_enable => true} context 'does nothing if service is unmanaged' do it 'runs successfully' do pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': admin_enable => true, service_manage => false, } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS shell('rm -f /var/lib/rabbitmq/rabbitmqadmin') @@ -50,28 +44,22 @@ class { 'erlang': epel_enable => true} it 'runs successfully' do # make sure credential change takes effect before admin_enable pp_pre = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, default_user => 'foobar', default_pass => 'bazblam', } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS pp = <<-EOS + class { 'erlang': } -> class { 'rabbitmq': admin_enable => true, service_manage => true, default_user => 'foobar', default_pass => 'bazblam', } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } EOS shell('rm -f /var/lib/rabbitmq/rabbitmqadmin') diff --git a/spec/acceptance/user_spec.rb b/spec/acceptance/user_spec.rb index a8d369218..e81193d55 100644 --- a/spec/acceptance/user_spec.rb +++ b/spec/acceptance/user_spec.rb @@ -6,10 +6,7 @@ context 'create user resource' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb index 782e33df9..563706d5f 100644 --- a/spec/acceptance/vhost_spec.rb +++ b/spec/acceptance/vhost_spec.rb @@ -6,10 +6,7 @@ context 'create vhost resource' do it 'runs successfully' do pp = <<-EOS - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true } - Class['erlang'] -> Class['rabbitmq'] - } + class { 'erlang': } -> class { 'rabbitmq': service_manage => true, port => 5672, diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index d89df2839..4e7a07453 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -36,21 +36,6 @@ it { is_expected.to contain_package('rabbitmq-server-plugins') } if os_facts[:os]['family'] == 'Suse' context 'with default params' do - it { is_expected.not_to contain_class('rabbitmq::repo::apt') } - it { is_expected.not_to contain_apt__source('rabbitmq') } - it { is_expected.not_to contain_class('rabbitmq::repo::rhel') } - it { is_expected.not_to contain_yumrepo('rabbitmq') } - end - - context 'with service_restart => false' do - let(:params) { { service_restart: false } } - - it { is_expected.not_to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') } - end - - context 'with repos_ensure => true' do - let(:params) { { repos_ensure: true } } - if os_facts[:os]['family'] == 'Debian' it 'includes rabbitmq::repo::apt' do is_expected.to contain_class('rabbitmq::repo::apt'). @@ -85,8 +70,23 @@ end end + context 'with service_restart => false' do + let(:params) { { service_restart: false } } + + it { is_expected.not_to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') } + end + + context 'with repos_ensure => false' do + let(:params) { { repos_ensure: false } } + + it { is_expected.not_to contain_class('rabbitmq::repo::apt') } + it { is_expected.not_to contain_apt__source('rabbitmq') } + it { is_expected.not_to contain_class('rabbitmq::repo::rhel') } + it { is_expected.not_to contain_yumrepo('rabbitmq') } + end + context 'with no pin', if: os_facts[:os]['family'] == 'Debian' do - let(:params) { { repos_ensure: true, package_apt_pin: '' } } + let(:params) { { package_apt_pin: '' } } describe 'it sets up an apt::source' do it { @@ -100,7 +100,7 @@ end context 'with pin', if: os_facts[:os]['family'] == 'Debian' do - let(:params) { { repos_ensure: true, package_apt_pin: '700' } } + let(:params) { { package_apt_pin: '700' } } describe 'it sets up an apt::source and pin' do it { @@ -234,7 +234,8 @@ is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin') end - it { is_expected.to contain_package('python') } if %w[RedHat Debian SUSE Archlinux].include?(os_facts[:os]['family']) + it { is_expected.to contain_package('python') } if %w[Debian SUSE Archlinux].include?(os_facts[:os]['family']) + it { is_expected.to contain_package('python3') } if %w[RedHat].include?(os_facts[:os]['family']) it { is_expected.to contain_package('python38') } if %w[FreeBSD].include?(os_facts[:os]['family']) end @@ -245,6 +246,7 @@ is_expected.to contain_class('rabbitmq::install::rabbitmqadmin') is_expected.not_to contain_package('python') is_expected.not_to contain_package('python2') + is_expected.not_to contain_package('python3') end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 94706e396..33062d664 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -3,11 +3,10 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' configure_beaker do |host| + install_module_from_forge_on(host, 'puppet-erlang', '>= 1.1.0 < 2.0.0') + case fact_on(host, 'os.family') - when 'Debian' - install_module_from_forge_on(host, 'puppetlabs-apt', '>= 4.1.0 < 9.0.0') when 'RedHat' - install_module_from_forge_on(host, 'garethr-erlang', '>= 0.3.0 < 1.0.0') if fact_on(host, 'os.selinux.enabled') # Make sure selinux is disabled so the tests work. on host, puppet('resource', 'exec', 'setenforce 0', 'path=/bin:/sbin:/usr/bin:/usr/sbin', 'onlyif=which setenforce && getenforce | grep Enforcing')