Skip to content

Commit

Permalink
Merge pull request #5 from jschneiderhan/COOK-1331
Browse files Browse the repository at this point in the history
COOK-1331 adding LWRP for enabling/disabling plugins
  • Loading branch information
Joshua Timberman committed Jul 12, 2012
2 parents 8aac3a2 + f6f0faf commit aa63e20
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down Expand Up @@ -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:
Expand All @@ -72,7 +90,7 @@ Author:: Benjamin Black <b@b3k.us>
Author:: Daniel DeLeo <dan@kallistec.com>
Author:: Matt Ray <matt@opscode.com>

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.
Expand Down
37 changes: 37 additions & 0 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
@@ -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

22 changes: 22 additions & 0 deletions resources/plugin.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aa63e20

Please sign in to comment.