From 5aea1f115a59515f57e34e0f3b6a6ec24d3c9274 Mon Sep 17 00:00:00 2001 From: David Gillies Date: Tue, 11 Nov 2014 10:16:22 +1100 Subject: [PATCH 1/2] create /tmp/.rabbitmqadmin.conf --- manifests/config.pp | 9 +++++++++ templates/rabbitmqadmin.conf.erb | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 templates/rabbitmqadmin.conf.erb diff --git a/manifests/config.pp b/manifests/config.pp index d97fce570..6f6407074 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -87,6 +87,15 @@ notify => Class['rabbitmq::service'], } + file { 'rabbitmqadmin.conf': + ensure => file, + path => '/tmp/.rabbitmqadmin.conf', + content => template('rabbitmq/rabbitmqadmin.conf.erb'), + owner => '0', + group => '0', + mode => '0644', + } + if $config_cluster { diff --git a/templates/rabbitmqadmin.conf.erb b/templates/rabbitmqadmin.conf.erb new file mode 100644 index 000000000..134308786 --- /dev/null +++ b/templates/rabbitmqadmin.conf.erb @@ -0,0 +1,8 @@ +[default] +<% if @ssl -%> +ssl = True +port = <%= @ssl_management_port %> +<% else -%> +ssl = False +port = <%= @management_port %> +<% end -%> From d6411ac663b5b96a03d80137b4e4d5c20bf69be5 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 14:36:51 -0800 Subject: [PATCH 2/2] Put rabbitmqadmin.conf in /etc/rabbitmq This commit puts rabbitmqadmin.conf in /etc/rabbitmq instead of /tmp so that puppet does not have to replace it if /tmp gets cleared. It also forces the rabbitmq_exchange provider to call rabbitmqadmin with -c /etc/rabbitmq/rabbitmqadmin.conf on both destroy and create so that both operations have access to the contents of the config file. --- lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb | 4 ++-- manifests/config.pp | 3 ++- .../puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb b/lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb index 0fa354db0..15f0aed8a 100644 --- a/lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb +++ b/lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb @@ -82,14 +82,14 @@ def exists? def create vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : '' name = resource[:name].split('@')[0] - rabbitmqadmin('declare', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", "type=#{resource[:type]}") + rabbitmqadmin('declare', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", "type=#{resource[:type]}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf') @property_hash[:ensure] = :present end def destroy vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : '' name = resource[:name].split('@')[0] - rabbitmqadmin('delete', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}") + rabbitmqadmin('delete', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf') @property_hash[:ensure] = :absent end diff --git a/manifests/config.pp b/manifests/config.pp index 6f6407074..d07861a03 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -89,11 +89,12 @@ file { 'rabbitmqadmin.conf': ensure => file, - path => '/tmp/.rabbitmqadmin.conf', + path => '/etc/rabbitmq/rabbitmqadmin.conf', content => template('rabbitmq/rabbitmqadmin.conf.erb'), owner => '0', group => '0', mode => '0644', + require => File['/etc/rabbitmq'], } diff --git a/spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb b/spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb index ac68970cf..89d6e94e3 100644 --- a/spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb +++ b/spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb @@ -36,12 +36,12 @@ end it 'should call rabbitmqadmin to create' do - @provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', 'type=topic') + @provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf') @provider.create end it 'should call rabbitmqadmin to destroy' do - @provider.expects(:rabbitmqadmin).with('delete', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct') + @provider.expects(:rabbitmqadmin).with('delete', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', '-c', '/etc/rabbitmq/rabbitmqadmin.conf') @provider.destroy end @@ -58,7 +58,7 @@ end it 'should call rabbitmqadmin to create' do - @provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=colin', '--password=secret', 'name=amq.direct', 'type=topic') + @provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=colin', '--password=secret', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf') @provider.create end end