Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

RabbitMq server install recipe #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions lib/deprec/recipes/rabbitmq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Capistrano::Configuration.instance(:must_exist).load do
namespace :deprec do
namespace :rabbitmq do

set :rabbtimq_user_uid, 899
set :rabbitmq_apt_key, "http://www.rabbitmq.com/rabbitmq-signing-key-public.asc"
set :rabbitmq_plugins, [
"http://www.rabbitmq.com/releases/plugins/v2.5.0/mochiweb-1.3-rmq2.5.0-git9a53dbd.ez",
"http://www.rabbitmq.com/releases/plugins/v2.5.0/webmachine-1.7.0-rmq2.5.0-hg0c4b60a.ez",
"http://www.rabbitmq.com/releases/plugins/v2.5.0/amqp_client-2.5.0.ez",
"http://www.rabbitmq.com/releases/plugins/v2.5.0/rabbitmq_mochiweb-2.5.0.ez",
"http://www.rabbitmq.com/releases/plugins/v2.5.0/rabbitmq_management_agent-2.5.0.ez",
"http://www.rabbitmq.com/releases/plugins/v2.5.0/rabbitmq_management-2.5.0.ez"
]
set :rabbitmq_plugins_dir, "/usr/lib/rabbitmq/lib/rabbitmq_server-2.5.0/plugins"
set :rabbitmq_port, 5672
set :rabbitmq_mochiweb_port, 55672

desc "Install RabbitMq 2.5.0"
task :install do
create_user
apt.add_source "deb http://www.rabbitmq.com/debian/ testing main", "http://www.rabbitmq.com/rabbitmq-signing-key-public.asc"
apt.install( {:base => %w(rabbitmq-server=2.5.0-1)}, :stable )
set_erlang_cookie
install_plugins
config
end

desc "Create rabbitmq user, and group (with specific uid)"
task :create_user do
sudo "addgroup --system --gid #{rabbtimq_user_uid} rabbitmq"
sudo "adduser --system --uid #{rabbtimq_user_uid} -gid #{rabbtimq_user_uid} rabbitmq"
logger.debug "rabbitmq user: #{capture("id rabbitmq")}"
end

desc "Copy .erlang.cookie file to rabbitmq users home"
task :set_erlang_cookie do
file = "/home/rabbitmq/.erlang.cookie"
deprec2.render_template(:rabbitmq, {:template => ".erlang.cookie", :remote => true, :mode => 0400, :owner => "rabbitmq", :path => file} )
sudo "chgrp rabbitmq #{file}"
end

desc "Install RabbitMq plugins"
task :install_plugins do
rabbitmq_plugins.each do |url|
run "cd #{rabbitmq_plugins_dir} && test -f #{File.basename(url)} || #{sudo} wget --quiet --timestamping #{url}"
end
end

desc "Create rabbitmq.config file from template"
task :config do
deprec2.render_template(:rabbitmq, {:template => "rabbitmq.config", :remote => true, :path => "/etc/rabbitmq/rabbitmq.config", :mode => 0644, :owner => 'root'} )
end


desc "Start RabbitMq"
task :start do
send(run_method, "/etc/init.d/rabbitmq-server start")
end

desc "Stop RabbitMq"
task :stop do
send(run_method, "/etc/init.d/rabbitmq-server stop")
end

desc "Restart RabbitMq"
task :restart do
send(run_method, "/etc/init.d/rabbitmq-server restart")
end

end
end
end
2 changes: 2 additions & 0 deletions lib/deprec/recipes_minus_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
require "#{File.dirname(__FILE__)}/recipes/vnstat"
require "#{File.dirname(__FILE__)}/recipes/utils"

require "#{File.dirname(__FILE__)}/recipes/rabbitmq"

# Retired recipes
#
# require "#{File.dirname(__FILE__)}/recipes/integrity"
Expand Down
1 change: 1 addition & 0 deletions lib/deprec/templates/rabbitmq/.erlang.cookie
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EKIGZDPPSCIPNNCIIMAZ
6 changes: 6 additions & 0 deletions lib/deprec/templates/rabbitmq/rabbitmq.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{rabbit, [ {tcp_listeners, [<%= rabbitmq_port %>]} ] },
{rabbit_mochiweb, [ {port, <%= rabbitmq_mochiweb_port %>} ] },
{rabbit_management, [ {http_log_dir, "/tmp/rabbit-mgmt"} ] },
{rabbit_management_agent, [ {force_fine_statistics, true} ] }
].
21 changes: 17 additions & 4 deletions lib/vmbuilder_plugins/apt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
# Installs within Capistrano as the plugin _apt_.
#
# =Usage
#
#
# require 'vmbuilder_plugins/apt'
#
# Prefix all calls to the library with <tt>apt.</tt>
#
module Apt
module Apt

# Default apt-get command - reduces any interactivity to the minimum.
APT_GET="DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"
APT_GET="DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"

# Run the apt install program across the package list in 'packages'.
# Run the apt install program across the package list in 'packages'.
# Select those packages referenced by <tt>:base</tt> and the +version+
# of the distribution you want to use.
def install(packages, version, options={})
Expand Down Expand Up @@ -79,6 +79,19 @@ def clear_cache(options={})
send(run_method, cmd, options)
end

# Adds line to /etc/apt/sources.list file
def add_source(line , key_url=nil)
sources = capture "cat /etc/apt/sources.list"
if !(sources =~ /#{line}/)
sudo "sed -i '1i #{line}' /etc/apt/sources.list"
if key_url
deprec2.download_src({:url => key_url}, src_dir)
sudo "apt-key add #{src_dir}/#{File.basename(key_url)}"
end
sudo "apt-get update"
end
end

private

# Provides a string containing all the package names in the base
Expand Down