Skip to content

Commit

Permalink
Ensure python package by default (when admin_enable and service_manag…
Browse files Browse the repository at this point in the history
…e are set) #618
  • Loading branch information
William Yardley committed Sep 9, 2017
1 parent 0e11237 commit 58205ea
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
# @param ldap_use_ssl Set to true to use SSL for the LDAP server.
# @param ldap_port Numeric port for LDAP server.
# @param ldap_log Set to true to log LDAP auth.
# @param manage_python If enabled, on platforms that don't provide a Python 2 package by default, ensure that the python package is
# installed (for rabbitmqadmin). This will only apply if `admin_enable` and `service_manage` are set.
# @param manage_repos Whether or not to manage package repositories.
# @param management_hostname The hostname for the RabbitMQ management interface.
# @param management_port The port for the RabbitMQ management interface.
Expand Down Expand Up @@ -213,6 +215,7 @@
Optional[String] $package_provider = undef,
Boolean $repos_ensure = $rabbitmq::params::repos_ensure,
$manage_repos = undef,
Boolean $manage_python = $rabbitmq::params::manage_python,
$rabbitmq_user = $rabbitmq::params::rabbitmq_user,
$rabbitmq_group = $rabbitmq::params::rabbitmq_group,
$rabbitmq_home = $rabbitmq::params::rabbitmq_home,
Expand Down
11 changes: 10 additions & 1 deletion manifests/install/rabbitmqadmin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

require '::archive'

$python_package = $rabbitmq::params::python_package
# Newer versions of Ubuntu (16.04) ship with Python 3 only by default.
if $rabbitmq::manage_python {
ensure_packages([$python_package])
$rabbitmqadmin_require = [Archive['rabbitmqadmin'], Package[$python_package]]
} else {
$rabbitmqadmin_require = Archive['rabbitmqadmin']
}

if($rabbitmq::ssl and $rabbitmq::management_ssl) {
$management_port = $rabbitmq::ssl_management_port
$protocol = 'https'
Expand Down Expand Up @@ -45,7 +54,7 @@
group => '0',
source => "${rabbitmq::rabbitmq_home}/rabbitmqadmin",
mode => '0755',
require => Archive['rabbitmqadmin'],
require => $rabbitmqadmin_require,
}

}
12 changes: 12 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

case $facts['os']['family'] {
'Archlinux': {
$manage_python = true
$python_package = 'python2'
$package_ensure = 'installed'
$package_name = 'rabbitmq'
$service_name = 'rabbitmq'
Expand All @@ -14,6 +16,8 @@
$rabbitmq_home = '/var/lib/rabbitmq'
}
'Debian': {
$manage_python = true
$python_package = 'python'
$package_ensure = 'installed'
$package_name = 'rabbitmq-server'
$service_name = 'rabbitmq-server'
Expand All @@ -22,6 +26,8 @@
$rabbitmq_home = '/var/lib/rabbitmq'
}
'OpenBSD': {
$manage_python = true
$python_package = 'python2'
$package_ensure = 'installed'
$package_name = 'rabbitmq'
$service_name = 'rabbitmq'
Expand All @@ -30,6 +36,8 @@
$rabbitmq_home = '/var/rabbitmq'
}
'FreeBSD': {
$manage_python = true
$python_package = 'python2'
$package_ensure = 'installed'
$package_name = 'rabbitmq'
$service_name = 'rabbitmq'
Expand All @@ -38,6 +46,8 @@
$rabbitmq_home = '/var/db/rabbitmq'
}
'RedHat': {
$manage_python = true
$python_package = 'python'
$package_ensure = 'installed'
$package_name = 'rabbitmq-server'
$service_name = 'rabbitmq-server'
Expand All @@ -46,6 +56,8 @@
$rabbitmq_home = '/var/lib/rabbitmq'
}
'SUSE': {
$manage_python = true
$python_package = 'python'
$package_ensure = 'installed'
$package_name = 'rabbitmq-server'
$service_name = 'rabbitmq-server'
Expand Down
15 changes: 10 additions & 5 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@

it {
is_expected.to contain_exec('rabbitmq-systemd-reload').with(
'command' => '/usr/bin/systemctl daemon-reload',
'notify' => 'Class[Rabbitmq::Service]',
'refreshonly' => true
command: '/usr/bin/systemctl daemon-reload',
notify: 'Class[Rabbitmq::Service]',
refreshonly: :true
)
}
end
Expand All @@ -197,18 +197,23 @@
it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
'notify' => 'Class[Rabbitmq::Service]'
notify: 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
end
if facts[:os]['family'] == 'Debian'
it 'python is in the catalog on Debian / Ubuntu' do
is_expected.to contain_package('python')
end
end
end
context 'with $management_ip_address undef and service_manage set to true' do
let(:params) { { admin_enable: true, management_ip_address: :undef } }

it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
'notify' => 'Class[Rabbitmq::Service]'
notify: 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://127.0.0.1:15672/cli/rabbitmqadmin')
end
Expand Down

0 comments on commit 58205ea

Please sign in to comment.