this should be able to control plugins

This commit is contained in:
Greg Cockburn 2012-01-09 20:11:26 +11:00
parent 3901f316e7
commit fbf180804b
2 changed files with 30 additions and 30 deletions

View File

@ -0,0 +1,30 @@
Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmq-plugins) do
commands :rabbitmq-plugins => 'rabbitmq-plugins'
defaultfor :feature => :posix
def self.instances
rabbitmq-plugins('list -e').split(/\n/).map do |line|
if line.split(/\s+/)[1] =~ /^(\S+)$/
new(:name => $1)
else
raise Puppet::Error, "Cannot parse invalid plugins line: #{line}"
end
end
end
def create
rabbitmq-plugins('enable', resource[:name])
end
def destroy
rabbitmq-plugins('disable', resource[:name])
end
def exists?
out = rabbitmq-plugins('list -e').split(/\n/).detect do |line|
line.split(/\s+/)[1].match(/^#{resource[:name]}$/)
end
end
end

View File

@ -1,30 +0,0 @@
Puppet::Type.type(:rabbitmq_vhost).provide(:rabbitmqctl) do
commands :rabbitmqctl => 'rabbitmqctl'
defaultfor :feature => :posix
def self.instances
rabbitmqctl('list_vhosts').split(/\n/)[1..-2].map do |line|
if line =~ /^(\S+)$/
new(:name => $1)
else
raise Puppet::Error, "Cannot parse invalid user line: #{line}"
end
end
end
def create
rabbitmqctl('add_vhost', resource[:name])
end
def destroy
rabbitmqctl('delete_vhost', resource[:name])
end
def exists?
out = rabbitmqctl('list_vhosts').split(/\n/)[1..-2].detect do |line|
line.match(/^#{resource[:name]}$/)
end
end
end