1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
2 Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, parent: Puppet::Provider::Rabbitmqctl) do
3 # Prefer rabbitmq-plugins if it's in $PATH, but fall back to /usr/lib/rabbitmq/bin
4 if Puppet::Util.which('rabbitmq-plugins')
5 has_command(:rabbitmqplugins, 'rabbitmq-plugins') do
6 environment HOME: '/tmp'
9 has_command(:rabbitmqplugins, '/usr/lib/rabbitmq/bin/rabbitmq-plugins') do
10 environment HOME: '/tmp'
14 confine feature: :posix
17 plugin_list = run_with_retries do
18 rabbitmqplugins('list', '-E', '-m')
21 plugin_list.split(%r{\n}).map do |line|
22 raise Puppet::Error, "Cannot parse invalid plugins line: #{line}" unless line =~ %r{^(\S+)$}
23 new(name: Regexp.last_match(1))
28 if resource[:umask].nil?
29 rabbitmqplugins('enable', resource[:name])
31 Puppet::Util.withumask(resource[:umask]) { rabbitmqplugins('enable', resource[:name]) }
36 rabbitmqplugins('disable', resource[:name])
40 self.class.run_with_retries { rabbitmqplugins('list', '-E', '-m') }.split(%r{\n}).include? resource[:name]