Skip to content

Commit

Permalink
Put rabbitmqadmin.conf in /etc/rabbitmq
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Colleen Murphy committed Dec 18, 2014
1 parent 5aea1f1 commit d6411ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit d6411ac

Please sign in to comment.