X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Flib%2Fpuppet%2Fprovider%2Frabbitmq_plugin%2Frabbitmqplugins.rb;fp=3rdparty%2Fmodules%2Frabbitmq%2Flib%2Fpuppet%2Fprovider%2Frabbitmq_plugin%2Frabbitmqplugins.rb;h=7ab5420c3af29610c6ecb6862ea8ee1fd7bce9f8;hb=24caa46729f80fbba4be8b9b26ebcb3acc4cb0fb;hp=9437cf35f9e4be9d79c252295f8b637094d27544;hpb=c7e7bcc28cc5dc48a7e284a3c82f33df27d1f57d;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb b/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb index 9437cf35f..7ab5420c3 100644 --- a/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb +++ b/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb @@ -1,35 +1,40 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl')) -Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, parent: Puppet::Provider::Rabbitmqctl) do - # Prefer rabbitmq-plugins if it's in $PATH, but fall back to /usr/lib/rabbitmq/bin - if Puppet::Util.which('rabbitmq-plugins') - has_command(:rabbitmqplugins, 'rabbitmq-plugins') do - environment HOME: '/tmp' +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' + else + commands :rabbitmqplugins => 'rabbitmq-plugins' end else - has_command(:rabbitmqplugins, '/usr/lib/rabbitmq/bin/rabbitmq-plugins') do - environment HOME: '/tmp' + if Facter.value(:osfamily) == 'RedHat' + has_command(:rabbitmqplugins, '/usr/lib/rabbitmq/bin/rabbitmq-plugins') do + environment :HOME => "/tmp" + end + else + has_command(:rabbitmqplugins, 'rabbitmq-plugins') do + environment :HOME => "/tmp" + end end end - confine feature: :posix + defaultfor :feature => :posix def self.instances - plugin_list = run_with_retries do + self.run_with_retries { rabbitmqplugins('list', '-E', '-m') - end - - plugin_list.split(%r{\n}).map do |line| - raise Puppet::Error, "Cannot parse invalid plugins line: #{line}" unless line =~ %r{^(\S+)$} - new(name: Regexp.last_match(1)) + }.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 - if resource[:umask].nil? - rabbitmqplugins('enable', resource[:name]) - else - Puppet::Util.withumask(resource[:umask]) { rabbitmqplugins('enable', resource[:name]) } - end + rabbitmqplugins('enable', resource[:name]) end def destroy @@ -37,6 +42,11 @@ Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, parent: Puppet::Pr end def exists? - self.class.run_with_retries { rabbitmqplugins('list', '-E', '-m') }.split(%r{\n}).include? resource[:name] + self.class.run_with_retries { + rabbitmqplugins('list', '-E', '-m') + }.split(/\n/).detect do |line| + line.match(/^#{resource[:name]}$/) + end end + end