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-1317] RabbitMQ cookbook is installing a very old / incorrect version of RabbitMQ #3

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions attributes/default.rb
Expand Up @@ -23,6 +23,7 @@
default[:rabbitmq][:cluster] = false
default[:rabbitmq][:cluster_disk_nodes] = []
default[:rabbitmq][:erlang_cookie] = 'AnyAlphaNumericStringWillDo'
default[:rabbitmq][:erlang_cookie_path] = '/var/lib/rabbitmq/.erlang.cookie'

#ssl
default[:rabbitmq][:ssl] = false
Expand Down
40 changes: 31 additions & 9 deletions recipes/default.rb
Expand Up @@ -4,6 +4,7 @@
#
# Copyright 2009, Benjamin Black
# Copyright 2009-2011, Opscode, Inc.
# Copyright 2012, Kevin Nuckolls <kevin.nuckolls@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,10 +19,6 @@
# limitations under the License.
#

# rabbitmq-server is not well-behaved as far as managed services goes
# we'll need to add a LWRP for calling rabbitmqctl stop
# while still using /etc/init.d/rabbitmq-server start
# because of this we just put the rabbitmq-env.conf in place and let it rip

include_recipe "erlang::default"

Expand Down Expand Up @@ -50,7 +47,10 @@
components ["main"]
key "http://www.rabbitmq.com/rabbitmq-signing-key-public.asc"
action :add
notifies :run, resources(:execute => "apt-get update"), :immediately
end
# installs the required setsid command -- should be there by default but just in case
package "util-linux"
package "rabbitmq-server"
when "redhat", "centos", "scientific", "amazon"
remote_file "/tmp/rabbitmq-server-#{node[:rabbitmq][:version]}-1.noarch.rpm" do
Expand All @@ -62,15 +62,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
if File.exists?(node[:rabbitmq][:erlang_cookie_path])
existing_erlang_key = File.read(node[:rabbitmq][:erlang_cookie_path])
else
existing_erlang_key = ""
end

if node[:rabbitmq][:cluster] and node[:rabbitmq][:erlang_cookie] != existing_erlang_key
execute "rabbitmq-stop" do
command "setsid /etc/init.d/rabbitmq-server stop"
action :run
end

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

execute "rabbitmq-start" do
command "setsid /etc/init.d/rabbitmq-server start"
action :run
end
end

Expand All @@ -82,8 +95,17 @@
notifies :restart, "service[rabbitmq-server]", :immediately
end

## You'll see setsid used in all the init statements in this cookbook. This
## is because there is a problem with the stock init script in the RabbitMQ
## debian package (at least in 2.8.2) that makes it not daemonize properly
## when called from chef. The setsid command forces the subprocess into a state
## where it can daemonize properly. -Kevin (thanks to Daniel DeLeo for the help)

service "rabbitmq-server" do
stop_command "/usr/sbin/rabbitmqctl stop"
start_command "setsid /etc/init.d/rabbitmq-server start"
stop_command "setsid /etc/init.d/rabbitmq-server stop"
restart_command "setsid /etc/init.d/rabbitmq-server restart"
status_command "setsid /etc/init.d/rabbitmq-server status"
supports :status => true, :restart => true
action [ :enable, :start ]
end