Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COOK-1493 fix system callout to properly determine if plugin is enabled #12

Merged
merged 3 commits into from
Sep 20, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
# limitations under the License.
#

def plugin_enabled?(name)
cmd = Mixlib::ShellOut.new("rabbitmq-plugins list -e '#{name}\\b'")
cmd.run_command
cmd.error!
cmd.stdout =~ /\b#{name}\b/
end

action :enable do
unless system("rabbitmq-plugins list #{new_resource.plugin} | grep '\\[[Ee]\\] #{new_resource.plugin}'")
unless plugin_enabled?(new_resource.plugin)
execute "rabbitmq-plugins enable #{new_resource.plugin}" do
Chef::Log.info "Enabling RabbitMQ plugin '#{new_resource.plugin}'."
new_resource.updated_by_last_action(true)
Expand All @@ -27,7 +34,7 @@
end

action :disable do
if system("rabbitmq-plugins list #{new_resource.plugin} | grep '\\[[Ee]\\] #{new_resource.plugin}'")
if plugin_enabled?(new_resource.plugin)
execute "rabbitmq-plugins disable #{new_resource.plugin}" do
Chef::Log.info "Disabling RabbitMQ plugin '#{new_resource.plugin}'."
new_resource.updated_by_last_action(true)
Expand Down