Skip to content

Commit

Permalink
Merge branch 'COOK-911'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Feb 13, 2012
2 parents 88e9fad + 90087b2 commit c079ccd
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 56 deletions.
10 changes: 6 additions & 4 deletions rabbitmq/README.md
Expand Up @@ -8,9 +8,9 @@ default
-------
Installs `rabbitmq-server` from RabbitMQ.com's APT repository or the RPM directly (there is no yum repo). The distribution-provided versions were quite old and newer features were needed.

cluster
-------
Configures nodes to be members of a RabbitMQ cluster, but does not actually join them.
Cluster recipe is now combined with default. Recipe will now auto-cluster. Set the :cluster attribute to true, :cluster_disk_nodes array of `node@host` strings that describe which you want to be disk nodes and then set an alphanumeric string for the :erlang_cookie.

To enable SSL turn :ssl to true and set the paths to your cacert, cert and key files.

Resources/Providers
===================
Expand Down Expand Up @@ -59,7 +59,9 @@ end

Limitations
===========
It is quite useful as is, but clustering configuration does not currently do the dance to join the cluster members to each other.
For an already running cluster, these actions still require manual intervention:
- changing the :erlang_cookie
- turning :cluster from true to false

The rabbitmq::chef recipe was only used for the chef-server cookbook and has been moved to chef-server::rabbitmq.

Expand Down
26 changes: 22 additions & 4 deletions rabbitmq/attributes/default.rb
@@ -1,10 +1,28 @@
default[:rabbitmq][:nodename] = node[:hostname]
# being nil, the rabbitmq defaults will be used
default[:rabbitmq][:nodename] = nil
default[:rabbitmq][:address] = nil
default[:rabbitmq][:port] = 5672
default[:rabbitmq][:port] = nil
default[:rabbitmq][:config] = nil
default[:rabbitmq][:logdir] = nil
default[:rabbitmq][:mnesiadir] = nil

# config file location
# http://www.rabbitmq.com/configure.html#define-environment-variables
# "The .config extension is automatically appended by the Erlang runtime."
default[:rabbitmq][:config] = "/etc/rabbitmq/rabbitmq"

# rabbitmq.config defaults
default[:rabbitmq][:default_user] = 'guest'
default[:rabbitmq][:default_pass] = 'guest'

#clustering
default[:rabbitmq][:cluster] = "no"
default[:rabbitmq][:cluster_config] = "/etc/rabbitmq/rabbitmq_cluster.config"
default[:rabbitmq][:cluster] = false
default[:rabbitmq][:cluster_disk_nodes] = []
default[:rabbitmq][:erlang_cookie] = 'AnyAlphaNumericStringWillDo'

#ssl
default[:rabbitmq][:ssl] = false
default[:rabbitmq][:ssl_port] = '5671'
default[:rabbitmq][:ssl_cacert] = '/path/to/cacert.pem'
default[:rabbitmq][:ssl_cert] = '/path/to/cert.pem'
default[:rabbitmq][:ssl_key] = '/path/to/key.pem'
35 changes: 0 additions & 35 deletions rabbitmq/recipes/cluster.rb

This file was deleted.

23 changes: 22 additions & 1 deletion rabbitmq/recipes/default.rb
Expand Up @@ -60,7 +60,28 @@
end
end

if node[:rabbitmq][:cluster]
# If this already exists, don't do anything
# Changing the cookie will stil have to be a manual process
template "/var/lib/rabbitmq/.erlang.cookie" do
source "doterlang.cookie.erb"
owner "rabbitmq"
group "rabbitmq"
mode 0400
not_if { File.exists? "/var/lib/rabbitmq/.erlang.cookie" }
end
end

template "/etc/rabbitmq/rabbitmq.config" do
source "rabbitmq.config.erb"
owner "root"
group "root"
mode 0644
notifies :restart, "service[rabbitmq-server]"
end

service "rabbitmq-server" do
stop_command "/usr/sbin/rabbitmqctl stop"
action [:enable, :start]
supports :status => true, :restart => true
action [ :enable, :start ]
end
14 changes: 7 additions & 7 deletions rabbitmq/templates/default/rabbitmq-env.conf.erb
@@ -1,10 +1,10 @@
###
# Generated by Chef for <%= node[:fqdn] %>
# Generated by Chef
###

NODENAME=<%= node[:rabbitmq][:nodename] %>
<% if node[:rabbitmq][:address] %>NODE_IP_ADDRESS=<%= node[:rabbitmq][:address] %><% end %>
<% if node[:rabbitmq][:port] %>NODE_PORT=<%= node[:rabbitmq][:port] %><% end %>
<% if node[:rabbitmq][:config] %>CONFIG_FILE=<%= node[:rabbitmq][:config] %><% end %>
<% if node[:rabbitmq][:logdir] %>LOG_BASE=<%= node[:rabbitmq][:logdir] %><% end %>
<% if node[:rabbitmq][:mnesiadir] %>MNESIA_BASE=<%= node[:rabbitmq][:mnesiadir] %><% end %>
<% if node[:rabbitmq][:nodename] -%>NODENAME=<%= node[:rabbitmq][:nodename] %><% end %>
<% if node[:rabbitmq][:address] -%>NODE_IP_ADDRESS=<%= node[:rabbitmq][:address] %><% end %>
<% if node[:rabbitmq][:port] -%>NODE_PORT=<%= node[:rabbitmq][:port] %><% end %>
<% if node[:rabbitmq][:config] -%>CONFIG_FILE=<%= node[:rabbitmq][:config] %><% end %>
<% if node[:rabbitmq][:logdir] -%>LOG_BASE=<%= node[:rabbitmq][:logdir] %><% end %>
<% if node[:rabbitmq][:mnesiadir] -%>MNESIA_BASE=<%= node[:rabbitmq][:mnesiadir] %><% end %>
21 changes: 21 additions & 0 deletions rabbitmq/templates/default/rabbitmq.config.erb
@@ -0,0 +1,21 @@
%%%
%% Generated by Chef
%%%

[
{rabbit, [
<% if node[:rabbitmq][:cluster] && node[:rabbitmq][:cluster_disk_nodes] -%>
{cluster_nodes, [<%= node[:rabbitmq][:cluster_disk_nodes].map{|n| "\'#{n}\'"}.join(',') %>]},
<% end %>
<% if node[:rabbitmq][:ssl] -%>
{ssl_listeners, [<%= node[:rabbitmq][:ssl_port] %>]},
{ssl_options, [{cacertfile,"<%= node[:rabbitmq][:ssl_cacert] %>"},
{certfile,"<%= node[:rabbitmq][:ssl_cert] %>"},
{keyfile,"<%= node[:rabbitmq][:ssl_key] %>"},
{verify,verify_none},
{fail_if_no_peer_cert,false}]},
<% end %>
{default_user, <<"<%= node[:rabbitmq][:default_user] %>">>},
{default_pass, <<"<%= node[:rabbitmq][:default_pass] %>">>}
]}
].
5 changes: 0 additions & 5 deletions rabbitmq/templates/default/rabbitmq_cluster.config.erb

This file was deleted.

0 comments on commit c079ccd

Please sign in to comment.