1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, :parent => Puppet::Provider::Rabbitmqctl) do
if Puppet::PUPPETVERSION.to_f < 3
if Facter.value(:osfamily) == 'RedHat'
commands :rabbitmqplugins => '/usr/lib/rabbitmq/bin/rabbitmq-plugins'
environment :LANG => "en_US.UTF-8"
else
commands :rabbitmqplugins => 'rabbitmq-plugins'
environment :LANG => "en_US.UTF-8"
end
else
if Facter.value(:osfamily) == 'RedHat'
has_command(:rabbitmqplugins, '/usr/lib/rabbitmq/bin/rabbitmq-plugins') do
environment :HOME => "/tmp", :LANG => "en_US.UTF-8"
end
else
has_command(:rabbitmqplugins, 'rabbitmq-plugins') do
environment :HOME => "/tmp", :LANG => "en_US.UTF-8"
end
end
end
defaultfor :feature => :posix
def self.instances
self.run_with_retries {
rabbitmqplugins('list', '-E', '-m')
}.split(/\n/).map do |line|
if line =~ /^(\S+)$/
new(:name => $1)
else
raise Puppet::Error, "Cannot parse invalid plugins line: #{line}"
end
end
end
def create
rabbitmqplugins('enable', resource[:name])
end
def destroy
rabbitmqplugins('disable', resource[:name])
end
def exists?
self.class.run_with_retries {
rabbitmqplugins('list', '-E', '-m')
}.split(/\n/).detect do |line|
line.match(/^#{resource[:name]}$/)
end
end
end
|