diff --git a/README.md b/README.md index 43b74862..2420763f 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To enable SSL turn :ssl to true and set the paths to your cacert, cert and key f Resources/Providers =================== -There are 2 LWRPs for interacting with RabbitMQ. +There are 3 LWRPs for interacting with RabbitMQ. user ---- @@ -57,6 +57,24 @@ rabbitmq_vhost "/nova" do end ``` +plugin +----- +Enables or disables a rabbitmq plugin. + +- `:enable` enables a `plugin` +- `:disable` disables a `plugin` + +### Example +``` ruby +rabbitmq_plugin "rabbitmq_stomp" do + action :enable +end + +rabbitmq_plugin "rabbitmq_shovel" do + action :disable +end +``` + Limitations =========== For an already running cluster, these actions still require manual intervention: @@ -72,7 +90,7 @@ Author:: Benjamin Black Author:: Daniel DeLeo Author:: Matt Ray -Copyright:: 2009-2011 Opscode, Inc +Copyright:: 2009-2012 Opscode, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/providers/plugin.rb b/providers/plugin.rb new file mode 100644 index 00000000..63a6b46d --- /dev/null +++ b/providers/plugin.rb @@ -0,0 +1,37 @@ +# +# Cookbook Name:: rabbitmq +# Provider:: plugin +# +# Copyright 2012, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +action :enable do + unless system("rabbitmq-plugins list #{new_resource.plugin} | grep '\\[[Ee]\\] #{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) + end + end +end + +action :disable do + if system("rabbitmq-plugins list #{new_resource.plugin} | grep '\\[[Ee]\\] #{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) + end + end +end + diff --git a/resources/plugin.rb b/resources/plugin.rb new file mode 100644 index 00000000..3504bcff --- /dev/null +++ b/resources/plugin.rb @@ -0,0 +1,22 @@ +# +# Cookbook Name:: rabbitmq +# Resource:: plugin +# +# Copyright 2011, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +actions :enable, :disable + +attribute :plugin, :kind_of => String, :name_attribute => true