diff --git a/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb b/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb index 6e05b7811..58c8b3c96 100644 --- a/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb +++ b/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb @@ -16,12 +16,12 @@ def exists? def content=(value) if resource[:force] == :true # Danger! puppet('resource', 'service', resource[:service_name], 'ensure=stopped') - FileUtils.rm_rf('/var/lib/rabbitmq/mnesia') + FileUtils.rm_rf(resource[:rabbitmq_home] + File::PATH_SEPARATOR + 'mnesia') File.open(resource[:path], 'w') do |cookie| cookie.chmod(0400) cookie.write(value) end - FileUtils.chown('rabbitmq', 'rabbitmq', resource[:path]) + FileUtils.chown(resource[:rabbitmq_user], resource[:rabbitmq_group], resource[:path]) else fail("The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this to happen automatically.") end diff --git a/manifests/config.pp b/manifests/config.pp index c111dab5b..e83bda986 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -18,6 +18,7 @@ $management_port = $rabbitmq::management_port $node_ip_address = $rabbitmq::node_ip_address $plugin_dir = $rabbitmq::plugin_dir + $rabbitmq_home = $rabbitmq::rabbitmq_home $port = $rabbitmq::port $tcp_keepalive = $rabbitmq::tcp_keepalive $service_name = $rabbitmq::service_name @@ -100,7 +101,7 @@ if $erlang_cookie == undef { fail('You must set the $erlang_cookie value in order to configure clustering.') } else { - rabbitmq_erlang_cookie { '/var/lib/rabbitmq/.erlang.cookie': + rabbitmq_erlang_cookie { "${rabbitmq_home}/.erlang.cookie": content => $erlang_cookie, force => $wipe_db_on_cookie_change, service_name => $service_name, diff --git a/manifests/init.pp b/manifests/init.pp index 138515ee3..d4a331934 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,6 +25,9 @@ $repos_ensure = $rabbitmq::params::repos_ensure, $manage_repos = $rabbitmq::params::manage_repos, $plugin_dir = $rabbitmq::params::plugin_dir, + $rabbitmq_user = $rabbitmq::params::rabbitmq_user, + $rabbitmq_group = $rabbitmq::params::rabbitmq_group, + $rabbitmq_home = $rabbitmq::params::rabbitmq_home, $port = $rabbitmq::params::port, $tcp_keepalive = $rabbitmq::params::tcp_keepalive, $service_ensure = $rabbitmq::params::service_ensure, @@ -183,6 +186,7 @@ } Class['::rabbitmq::service'] -> Class['::rabbitmq::install::rabbitmqadmin'] + Class['::rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |> } if $stomp_ensure { @@ -212,6 +216,5 @@ # Make sure the various providers have their requirements in place. Class['::rabbitmq::install'] -> Rabbitmq_plugin<| |> - Class['::rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |> } diff --git a/manifests/install/rabbitmqadmin.pp b/manifests/install/rabbitmqadmin.pp index 5b9f527b9..bf545eea4 100644 --- a/manifests/install/rabbitmqadmin.pp +++ b/manifests/install/rabbitmqadmin.pp @@ -13,7 +13,7 @@ $protocol = $rabbitmq::ssl ? { false => 'http', default => 'https' } staging::file { 'rabbitmqadmin': - target => '/var/lib/rabbitmq/rabbitmqadmin', + target => "${rabbitmq::rabbitmq_home}/rabbitmqadmin", source => "${protocol}://${default_user}:${default_pass}@localhost:${management_port}/cli/rabbitmqadmin", curl_option => '-k --noproxy localhost --retry 30 --retry-delay 6', timeout => '180', @@ -26,8 +26,8 @@ file { '/usr/local/bin/rabbitmqadmin': owner => 'root', - group => 'root', - source => '/var/lib/rabbitmq/rabbitmqadmin', + group => '0', + source => "${rabbitmq::rabbitmq_home}/rabbitmqadmin", mode => '0755', require => Staging::File['rabbitmqadmin'], } diff --git a/manifests/params.pp b/manifests/params.pp index f57b1f9c0..b09d7620a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,6 +10,10 @@ $package_name = 'rabbitmq' $service_name = 'rabbitmq' $version = '3.1.3-1' + $rabbitmq_user = 'rabbitmq' + $rabbitmq_group = 'rabbitmq' + $rabbitmq_home = '/var/lib/rabbitmq' + $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" } 'Debian': { $package_ensure = 'installed' @@ -17,6 +21,20 @@ $service_name = 'rabbitmq-server' $package_provider = 'apt' $version = '3.1.5' + $rabbitmq_user = 'rabbitmq' + $rabbitmq_group = 'rabbitmq' + $rabbitmq_home = '/var/lib/rabbitmq' + $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" + } + 'OpenBSD': { + $package_ensure = 'installed' + $package_name = 'rabbitmq' + $service_name = 'rabbitmq' + $version = '3.4.2' + $rabbitmq_user = '_rabbitmq' + $rabbitmq_group = '_rabbitmq' + $rabbitmq_home = '/var/rabbitmq' + $plugin_dir = '/usr/local/lib/rabbitmq/plugins' } 'RedHat': { $package_ensure = 'installed' @@ -24,6 +42,10 @@ $service_name = 'rabbitmq-server' $package_provider = 'rpm' $version = '3.1.5-1' + $rabbitmq_user = 'rabbitmq' + $rabbitmq_group = 'rabbitmq' + $rabbitmq_home = '/var/lib/rabbitmq' + $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" } 'SUSE': { $package_ensure = 'installed' @@ -31,6 +53,10 @@ $service_name = 'rabbitmq-server' $package_provider = 'zypper' $version = '3.1.5-1' + $rabbitmq_user = 'rabbitmq' + $rabbitmq_group = 'rabbitmq' + $rabbitmq_home = '/var/lib/rabbitmq' + $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" } default: { fail("The ${module_name} module is not supported on an ${::osfamily} based system.") @@ -61,7 +87,6 @@ $erlang_cookie = undef $interface = 'UNSET' $node_ip_address = 'UNSET' - $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" $port = '5672' $tcp_keepalive = false $ssl = false