Skip to content

Commit d6411ac

Browse files
author
Colleen Murphy
committed
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.
1 parent 5aea1f1 commit d6411ac

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ def exists?
8282
def create
8383
vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : ''
8484
name = resource[:name].split('@')[0]
85-
rabbitmqadmin('declare', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", "type=#{resource[:type]}")
85+
rabbitmqadmin('declare', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", "type=#{resource[:type]}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
8686
@property_hash[:ensure] = :present
8787
end
8888

8989
def destroy
9090
vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : ''
9191
name = resource[:name].split('@')[0]
92-
rabbitmqadmin('delete', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}")
92+
rabbitmqadmin('delete', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
9393
@property_hash[:ensure] = :absent
9494
end
9595

manifests/config.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@
8989

9090
file { 'rabbitmqadmin.conf':
9191
ensure => file,
92-
path => '/tmp/.rabbitmqadmin.conf',
92+
path => '/etc/rabbitmq/rabbitmqadmin.conf',
9393
content => template('rabbitmq/rabbitmqadmin.conf.erb'),
9494
owner => '0',
9595
group => '0',
9696
mode => '0644',
97+
require => File['/etc/rabbitmq'],
9798
}
9899

99100

spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
end
3737

3838
it 'should call rabbitmqadmin to create' do
39-
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', 'type=topic')
39+
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
4040
@provider.create
4141
end
4242

4343
it 'should call rabbitmqadmin to destroy' do
44-
@provider.expects(:rabbitmqadmin).with('delete', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct')
44+
@provider.expects(:rabbitmqadmin).with('delete', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
4545
@provider.destroy
4646
end
4747

@@ -58,7 +58,7 @@
5858
end
5959

6060
it 'should call rabbitmqadmin to create' do
61-
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=colin', '--password=secret', 'name=amq.direct', 'type=topic')
61+
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=colin', '--password=secret', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
6262
@provider.create
6363
end
6464
end

0 commit comments

Comments
 (0)