Permalink
Browse files

Auto-cluster, SSL and attributes

- combined cluster and default recipe into one; :cluster switch on and off
- added auto-clustering
- added ssl support
- added default user/pass control through attributes
  • Loading branch information...
1 parent eca2e0b commit e1ddb88a7ddaa8deb0c257339515efd0238ab5aa @harlanbarnes harlanbarnes committed with jtimberman Dec 22, 2011
View
8 rabbitmq/README.md
@@ -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
===================
@@ -59,7 +59,7 @@ 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.
+Changing the :erlang_cookie or turning :cluster from true to false will require manual intervention
The rabbitmq::chef recipe was only used for the chef-server cookbook and has been moved to chef-server::rabbitmq.
View
26 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] = 'rabbitmq'
+default[:rabbitmq][:default_pass] = 'rabbitmq321go'
+
#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'
View
23 rabbitmq/recipes/default.rb
@@ -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
View
14 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 %>

0 comments on commit e1ddb88

Please sign in to comment.