wr0ngway-rubber 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/COPYING +339 -0
- data/README +6 -0
- data/TODO +7 -0
- data/VERSION +1 -0
- data/bin/vulcanize +41 -0
- data/generators/vulcanize/USAGE +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +5 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +62 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +30 -0
- data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +7 -0
- data/generators/vulcanize/templates/apache/templates.yml +1 -0
- data/generators/vulcanize/templates/base/Capfile +14 -0
- data/generators/vulcanize/templates/base/config/deploy.rb +55 -0
- data/generators/vulcanize/templates/base/config/rubber/common/crontab +16 -0
- data/generators/vulcanize/templates/base/config/rubber/common/profile.rc +9 -0
- data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +104 -0
- data/generators/vulcanize/templates/base/config/rubber/rubber.yml +241 -0
- data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
- data/generators/vulcanize/templates/base/script/cron-rake +18 -0
- data/generators/vulcanize/templates/base/script/cron-runner +18 -0
- data/generators/vulcanize/templates/base/script/cron-sh +67 -0
- data/generators/vulcanize/templates/base/templates.yml +1 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/role/haproxy/haproxy-passenger.conf +19 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/rubber-complete.yml +40 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +10 -0
- data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
- data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
- data/generators/vulcanize/templates/cruise/templates.yml +1 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +6 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +17 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
- data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
- data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
- data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
- data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
- data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
- data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
- data/generators/vulcanize/templates/memcached/templates.yml +1 -0
- data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
- data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
- data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
- data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
- data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +251 -0
- data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +32 -0
- data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
- data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
- data/generators/vulcanize/templates/monit/templates.yml +1 -0
- data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
- data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
- data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +80 -0
- data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
- data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +57 -0
- data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
- data/generators/vulcanize/templates/munin/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +11 -0
- data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +156 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +167 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
- data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +46 -0
- data/generators/vulcanize/templates/mysql/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +173 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
- data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
- data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
- data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
- data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
- data/generators/vulcanize/templates/nginx/templates.yml +1 -0
- data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +37 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +6 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +10 -0
- data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +12 -0
- data/generators/vulcanize/templates/passenger/templates.yml +1 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +10 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
- data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
- data/generators/vulcanize/vulcanize_generator.rb +67 -0
- data/lib/capistrano/hostcmd.rb +12 -0
- data/lib/rubber/capistrano.rb +1 -0
- data/lib/rubber/cloud/aws.rb +305 -0
- data/lib/rubber/cloud/base.rb +16 -0
- data/lib/rubber/cloud.rb +13 -0
- data/lib/rubber/configuration.rb +47 -0
- data/lib/rubber/dns/base.rb +69 -0
- data/lib/rubber/dns/dyndns.rb +63 -0
- data/lib/rubber/dns/nettica.rb +56 -0
- data/lib/rubber/dns/zerigo.rb +121 -0
- data/lib/rubber/dns.rb +13 -0
- data/lib/rubber/environment.rb +161 -0
- data/lib/rubber/generator.rb +197 -0
- data/lib/rubber/instance.rb +165 -0
- data/lib/rubber/recipes/rubber/bundles.rb +28 -0
- data/lib/rubber/recipes/rubber/deploy.rb +90 -0
- data/lib/rubber/recipes/rubber/instances.rb +348 -0
- data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
- data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
- data/lib/rubber/recipes/rubber/setup.rb +357 -0
- data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
- data/lib/rubber/recipes/rubber/utils.rb +203 -0
- data/lib/rubber/recipes/rubber/volumes.rb +264 -0
- data/lib/rubber/recipes/rubber.rb +89 -0
- data/lib/rubber/tasks/rubber.rb +221 -0
- data/lib/rubber/util.rb +37 -0
- data/lib/rubber.rb +38 -0
- data/test/environment_test.rb +118 -0
- data/test/generator_test.rb +323 -0
- data/test/instance_test.rb +93 -0
- data/test/test_helper.rb +4 -0
- data/test/util_test.rb +16 -0
- metadata +273 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/var/www/index.html"
|
3
|
+
%>
|
4
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
8
|
+
<title>Rubber Admin Tools</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Rubber Admin Tools</h1>
|
12
|
+
<ul>
|
13
|
+
|
14
|
+
<li><a href="/munin/">Munin</a></li>
|
15
|
+
|
16
|
+
<% if cruise_host = rubber_instances.for_role('cruise').first %>
|
17
|
+
<li><a href="http://<%= cruise_host %>/cruise/">CruiseControl</a></li>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<% rubber_instances.for_role('haproxy').each do |ic| %>
|
21
|
+
<li><a href="/haproxy_<%= ic.name %>/">HAProxy <%= ic.name %></a></li>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% rubber_instances.each do |ic| %>
|
25
|
+
<li><a href="/monit_<%= ic.name %>/">Monit <%= ic.name %></a></li>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
</ul>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
description: The apache module
|
@@ -0,0 +1,14 @@
|
|
1
|
+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
2
|
+
|
3
|
+
env = ENV['RUBBER_ENV'] ||= (ENV['RAILS_ENV'] || 'production')
|
4
|
+
root = File.dirname(__FILE__)
|
5
|
+
|
6
|
+
# this tries first as a rails plugin then as a gem
|
7
|
+
$:.unshift "#{root}/vendor/plugins/rubber/lib/"
|
8
|
+
require 'rubber'
|
9
|
+
|
10
|
+
Rubber::initialize(root, env)
|
11
|
+
require 'rubber/capistrano'
|
12
|
+
|
13
|
+
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
14
|
+
load 'config/deploy'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# This is a sample Capistrano config file for rubber
|
2
|
+
|
3
|
+
set :rails_env, RUBBER_ENV
|
4
|
+
|
5
|
+
on :load do
|
6
|
+
set :application, rubber_env.app_name
|
7
|
+
set :runner, rubber_env.app_user
|
8
|
+
set :deploy_to, "/mnt/#{application}-#{RUBBER_ENV}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Use a simple directory tree copy here to make demo easier.
|
12
|
+
# You probably want to use your own repository for a real app
|
13
|
+
set :scm, :none
|
14
|
+
set :repository, "."
|
15
|
+
set :deploy_via, :copy
|
16
|
+
|
17
|
+
# Easier to do system level config as root - probably should do it through
|
18
|
+
# sudo in the future. We use ssh keys for access, so no passwd needed
|
19
|
+
set :user, 'root'
|
20
|
+
set :password, nil
|
21
|
+
|
22
|
+
# Use sudo with user rails for cap deploy:[stop|start|restart]
|
23
|
+
# This way exposed services (mongrel) aren't running as a privileged user
|
24
|
+
set :use_sudo, true
|
25
|
+
|
26
|
+
# How many old releases should be kept around when running "cleanup" task
|
27
|
+
set :keep_releases, 3
|
28
|
+
|
29
|
+
# Lets us work with staging instances without having to checkin config files
|
30
|
+
# (instance*.yml + rubber*.yml) for a deploy. This gives us the
|
31
|
+
# convenience of not having to checkin files for staging, as well as
|
32
|
+
# the safety of forcing it to be checked in for production.
|
33
|
+
set :push_instance_config, RUBBER_ENV != 'production'
|
34
|
+
|
35
|
+
# Allows the tasks defined to fail gracefully if there are no hosts for them.
|
36
|
+
# Comment out or use "required_task" for default cap behavior of a hard failure
|
37
|
+
rubber.allow_optional_tasks(self)
|
38
|
+
# Wrap tasks in the deploy namespace that have roles so that we can use FILTER
|
39
|
+
# with something like a deploy:cold which tries to run deploy:migrate but can't
|
40
|
+
# because we filtered out the :db role
|
41
|
+
namespace :deploy do
|
42
|
+
rubber.allow_optional_tasks(self)
|
43
|
+
tasks.values.each do |t|
|
44
|
+
if t.options[:roles]
|
45
|
+
task t.name, t.options, &t.body
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# load in the deploy scripts installed by vulcanize for each rubber module
|
51
|
+
Dir["#{File.dirname(__FILE__)}/rubber/deploy-*.rb"].each do |deploy_file|
|
52
|
+
load deploy_file
|
53
|
+
end
|
54
|
+
|
55
|
+
after "deploy", "deploy:cleanup"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%
|
2
|
+
@read_cmd = 'crontab -l'
|
3
|
+
@write_cmd = 'crontab -'
|
4
|
+
%>
|
5
|
+
|
6
|
+
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/sbin:/usr/sbin
|
7
|
+
MAILTO=<%= rubber_env.admin_email %>
|
8
|
+
# don't need to set RUBBER_ENV for each script since we set it for all cron here
|
9
|
+
RUBBER_ENV=<%= RUBBER_ENV %>
|
10
|
+
RAILS_ENV=<%= RUBBER_ENV %>
|
11
|
+
|
12
|
+
# Roll all rails logs at midnight
|
13
|
+
0 0 * * * LOG_DIR=<%= RUBBER_ROOT %>/log <%= RUBBER_ROOT %>/script/cron-rake rubber:rotate_logs
|
14
|
+
|
15
|
+
# Automatically set the clock for all machines
|
16
|
+
<%= rand(60) %> 4 * * * <%= RUBBER_ROOT %>/script/cron-sh -- ntpdate pool.ntp.org
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/root/.profile"
|
3
|
+
@additive = ["# rubber-common-start", "# rubber-common-end"]
|
4
|
+
%>
|
5
|
+
|
6
|
+
# convenience to simply running rails console, etc with correct env
|
7
|
+
export RUBBER_ENV=<%= RUBBER_ENV %>
|
8
|
+
export RAILS_ENV=<%= RUBBER_ENV %>
|
9
|
+
alias current="cd <%= RUBBER_ROOT %>"
|
@@ -0,0 +1,104 @@
|
|
1
|
+
namespace :rubber do
|
2
|
+
namespace :base do
|
3
|
+
|
4
|
+
rubber.allow_optional_tasks(self)
|
5
|
+
|
6
|
+
|
7
|
+
before "rubber:install_packages", "rubber:base:pre_install_ruby"
|
8
|
+
task :pre_install_ruby do
|
9
|
+
|
10
|
+
# figure out which hosts we have specified enterprise ruby for
|
11
|
+
sys_ruby_hosts = []
|
12
|
+
ent_ruby_hosts = []
|
13
|
+
rubber_instances.filtered.each do |ic|
|
14
|
+
env = rubber_cfg.environment.bind(ic.role_names, ic.name)
|
15
|
+
if env.use_enterprise_ruby
|
16
|
+
ent_ruby_hosts << ic.full_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if ent_ruby_hosts.size > 0
|
21
|
+
|
22
|
+
task :_install_enterprise_ruby, :hosts => ent_ruby_hosts do
|
23
|
+
|
24
|
+
# preferences to pick up specific Ruby packages from brightbox
|
25
|
+
prefs = <<-DATA
|
26
|
+
Package: *
|
27
|
+
Pin: release l=brightbox
|
28
|
+
Pin-Priority: 1001
|
29
|
+
|
30
|
+
Package: ruby1.8-elisp
|
31
|
+
Pin: release l=Ubuntu
|
32
|
+
Pin-Priority: 1001
|
33
|
+
DATA
|
34
|
+
|
35
|
+
prefs.gsub!(/^ */, '') # remove leading whitespace
|
36
|
+
put(prefs, '/etc/apt/preferences')
|
37
|
+
|
38
|
+
rubber.sudo_script 'install_enterprise_ruby', <<-ENDSCRIPT
|
39
|
+
wget http://apt.brightbox.net/release.asc -O - | apt-key add -
|
40
|
+
echo "deb http://apt.brightbox.net/ hardy rubyee" > /etc/apt/sources.list.d/brightbox-rubyee.list
|
41
|
+
ENDSCRIPT
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
_install_enterprise_ruby
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# The ubuntu rubygem package is woefully out of date, so install it manually
|
51
|
+
after "rubber:install_packages", "rubber:base:install_rubygems"
|
52
|
+
task :install_rubygems do
|
53
|
+
ver = "1.3.5"
|
54
|
+
src_url = "http://rubyforge.org/frs/download.php/60718/rubygems-#{ver}.tgz"
|
55
|
+
rubber.sudo_script 'install_rubygems', <<-ENDSCRIPT
|
56
|
+
if [[ `gem --version 2>&1` != "#{ver}" ]]; then
|
57
|
+
wget -qNP /tmp #{src_url}
|
58
|
+
tar -C /tmp -xzf /tmp/rubygems-#{ver}.tgz
|
59
|
+
ruby -C /tmp/rubygems-#{ver} setup.rb
|
60
|
+
ln -sf /usr/bin/gem1.8 /usr/bin/gem
|
61
|
+
rm -rf /tmp/rubygems*
|
62
|
+
gem source -l > /dev/null
|
63
|
+
fi
|
64
|
+
ENDSCRIPT
|
65
|
+
end
|
66
|
+
|
67
|
+
# git in ubuntu 7.0.4 is very out of date and doesn't work well with capistrano
|
68
|
+
after "rubber:install_packages", "rubber:base:install_git" if scm == "git"
|
69
|
+
task :install_git do
|
70
|
+
rubber.run_script 'install_git', <<-ENDSCRIPT
|
71
|
+
if ! git --version &> /dev/null; then
|
72
|
+
arch=`uname -m`
|
73
|
+
if [ "$arch" = "x86_64" ]; then
|
74
|
+
src="http://mirrors.kernel.org/ubuntu/pool/main/g/git-core/git-core_1.5.4.5-1~dapper1_amd64.deb"
|
75
|
+
else
|
76
|
+
src="http://mirrors.kernel.org/ubuntu/pool/main/g/git-core/git-core_1.5.4.5-1~dapper1_i386.deb"
|
77
|
+
fi
|
78
|
+
apt-get install liberror-perl libdigest-sha1-perl
|
79
|
+
wget -qO /tmp/git.deb ${src}
|
80
|
+
dpkg -i /tmp/git.deb
|
81
|
+
|
82
|
+
if [[ "#{repository}" =~ "@" ]]; then
|
83
|
+
# Get host key for src machine to prevent ssh from failing
|
84
|
+
rm -f ~/.ssh/known_hosts
|
85
|
+
! ssh -o 'StrictHostKeyChecking=no' #{repository.gsub(/:.*/, '')} &> /dev/null
|
86
|
+
fi
|
87
|
+
fi
|
88
|
+
ENDSCRIPT
|
89
|
+
end
|
90
|
+
|
91
|
+
# We need a rails user for safer permissions used by deploy.rb
|
92
|
+
after "rubber:install_packages", "rubber:base:custom_install"
|
93
|
+
task :custom_install do
|
94
|
+
rubber.sudo_script 'custom_install', <<-ENDSCRIPT
|
95
|
+
# add the user for running app server with
|
96
|
+
if ! id #{rubber_env.app_user} &> /dev/null; then adduser --system --group #{rubber_env.app_user}; fi
|
97
|
+
|
98
|
+
# add ssh keys for root
|
99
|
+
if [[ ! -f /root/.ssh/id_dsa ]]; then ssh-keygen -q -t dsa -N '' -f /root/.ssh/id_dsa; fi
|
100
|
+
ENDSCRIPT
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
# All variables can also be overridden on the role and/or host level by creating
|
2
|
+
# a sub level to the config under roles and hosts
|
3
|
+
# e.g. to install mysql only on db role, and awstats only on web01:
|
4
|
+
#
|
5
|
+
# packages: [ruby]
|
6
|
+
# roles:
|
7
|
+
# db:
|
8
|
+
# packages: [mysql]
|
9
|
+
# hosts:
|
10
|
+
# web01:
|
11
|
+
# packages: [awstats]
|
12
|
+
|
13
|
+
# REQUIRED: The name of your application
|
14
|
+
app_name: "#{File.basename(RUBBER_ROOT)}"
|
15
|
+
|
16
|
+
# REQUIRED: The system user to run your app servers as
|
17
|
+
app_user: app
|
18
|
+
|
19
|
+
# REQUIRED: Notification emails (e.g. monit) get sent to this address
|
20
|
+
#
|
21
|
+
admin_email: root@localhost
|
22
|
+
|
23
|
+
# OPTIONAL: If not set, you won't be able to access web_tools
|
24
|
+
# server (munin stats, monit status, etc)
|
25
|
+
# web_tools_user: admin
|
26
|
+
# web_tools_password: sekret
|
27
|
+
|
28
|
+
# REQUIRED: The timezone the server should be in
|
29
|
+
timezone: US/Eastern
|
30
|
+
|
31
|
+
# REQUIRED: the domain all the instances should be associated with
|
32
|
+
#
|
33
|
+
domain: foo.com
|
34
|
+
|
35
|
+
# OPTIONAL: The configuration for each dns provider (nettica|zerigo|dyndns)
|
36
|
+
# This lets rubber updatea dynamic dns service with the instance alias and ip
|
37
|
+
#
|
38
|
+
dns_providers:
|
39
|
+
nettica:
|
40
|
+
user: joe
|
41
|
+
password: sekret
|
42
|
+
record_type: A
|
43
|
+
ttl: 300
|
44
|
+
zerigo:
|
45
|
+
customer_id: 1234
|
46
|
+
email: foo@bar.com
|
47
|
+
token: hexxy
|
48
|
+
record_type: A
|
49
|
+
ttl: 300
|
50
|
+
dyndns:
|
51
|
+
user: joe
|
52
|
+
password: sekret
|
53
|
+
update_url: https://members.dyndns.org/nic/update?hostname=%host%&myip=%ip%'
|
54
|
+
|
55
|
+
# OPTIONAL: The dns provider to use
|
56
|
+
# dns_provider: nettica
|
57
|
+
|
58
|
+
# OPTIONAL: Additional rubber file to pull config from if it exists. This file will
|
59
|
+
# also be pushed to remote host at RUBBER_ROOT/config/rubber/rubber-secret.yml
|
60
|
+
#
|
61
|
+
# rubber_secret: "#{File.expand_path('~') + '/.ec2' + (RUBBER_ENV == 'production' ? '' : '_dev') + '/rubber-secret.yml' rescue ''}"
|
62
|
+
|
63
|
+
# REQUIRED All known cloud providers with the settings needed to configure them
|
64
|
+
# There's only one coud provider right now - Amazon Web Services
|
65
|
+
# To implement another, clone lib/rubber/cloud/aws.rb
|
66
|
+
#
|
67
|
+
cloud_providers:
|
68
|
+
aws:
|
69
|
+
# REQUIRED The amazon keys and account ID (digits only, no dashes) used to access the AWS API
|
70
|
+
#
|
71
|
+
access_key: XXX
|
72
|
+
secret_access_key: YYY
|
73
|
+
account: ZZZ
|
74
|
+
|
75
|
+
# REQUIRED: The name of the amazon keypair and location of its private key
|
76
|
+
#
|
77
|
+
# NOTE: for some reason Capistrano requires you to have both the public and
|
78
|
+
# the private key in the same folder, the public key should have the
|
79
|
+
# extension ".pub". The easiest (only?) way to get your hand on this is to
|
80
|
+
# create an instance, ssh into it, and copy the file /mnt/openssh_id.pub
|
81
|
+
#
|
82
|
+
key_name: gsg-keypair
|
83
|
+
key_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/*' + cloud_providers.aws.key_name].first}"
|
84
|
+
|
85
|
+
# OPTIONAL: Needed for bundling a running instance using rubber:bundle
|
86
|
+
#
|
87
|
+
# pk_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/pk-*'].first}"
|
88
|
+
# cert_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/cert-*'].first}"
|
89
|
+
# image_bucket: "#{app_name}_images"
|
90
|
+
|
91
|
+
# OPTIONAL: Needed for backing up database to s3
|
92
|
+
# backup_bucket: "#{app_name}_backups"
|
93
|
+
|
94
|
+
# REQUIRED: the ami and instance type for creating instances
|
95
|
+
# The Ubuntu images at http://alestic.com/ work well
|
96
|
+
# Ubuntu 9.04 Jaunty base install 32-bit 2.6.21.7-2.fc8xen ami-ed46a784
|
97
|
+
# Ubuntu 9.04 Jaunty base install 64-bit 2.6.21.7-2.fc8xen ami-5b46a732
|
98
|
+
#
|
99
|
+
image_id: ami-ed46a784
|
100
|
+
# m1.small or m1.large or m1.xlarge
|
101
|
+
image_type: m1.small
|
102
|
+
|
103
|
+
# REQUIRED the cloud provider to use
|
104
|
+
#
|
105
|
+
cloud_provider: aws
|
106
|
+
|
107
|
+
# OPTIONAL: Define security groups
|
108
|
+
# Each security group is a name associated with a sequence of maps where the
|
109
|
+
# keys are the parameters to the ec2 AuthorizeSecurityGroupIngress API
|
110
|
+
# source_security_group_name, source_security_group_owner_id
|
111
|
+
# ip_protocol, from_port, to_port, cidr_ip
|
112
|
+
#
|
113
|
+
security_groups:
|
114
|
+
default:
|
115
|
+
description: The default security group
|
116
|
+
rules:
|
117
|
+
- source_group_name: default
|
118
|
+
source_group_account: "#{cloud_providers.aws.account}"
|
119
|
+
- protocol: tcp
|
120
|
+
from_port: 22
|
121
|
+
to_port: 22
|
122
|
+
source_ips: [0.0.0.0/0]
|
123
|
+
|
124
|
+
# OPTIONAL: The default security groups to create instances with
|
125
|
+
assigned_security_groups: [default]
|
126
|
+
|
127
|
+
# OPTIONAL: Automatically create security groups for each host and role
|
128
|
+
# EC2 doesn't allow one to change what groups an instance belongs to after
|
129
|
+
# creation, so its good to have some empty ones predefined.
|
130
|
+
auto_security_groups: true
|
131
|
+
|
132
|
+
# OPTIONAL: Automatically isolate security groups for each appname/environment
|
133
|
+
# by mangling their names to be appname_env_groupname
|
134
|
+
# This makes it safer to have staging and production coexist on the same EC2
|
135
|
+
# account, or even multiple apps
|
136
|
+
isolate_security_groups: true
|
137
|
+
|
138
|
+
# OPTIONAL: Set if you want to use Ruby Enterprise Edition instead of the standard ubuntu one
|
139
|
+
use_enterprise_ruby: false
|
140
|
+
|
141
|
+
# OPTIONAL: The packages to install on all instances
|
142
|
+
# You can install a specific version of a package by using a sub-array of pkg, version
|
143
|
+
# For example, packages: [[rake, 0.7.1], irb]
|
144
|
+
packages: [postfix, build-essential, ruby-full, ruby1.8-dev, rake, irb]
|
145
|
+
|
146
|
+
# OPTIONAL: gem sources to setup for rubygems
|
147
|
+
gemsources: ["http://gems.rubyforge.org/", "http://gems.github.com"]
|
148
|
+
|
149
|
+
# OPTIONAL: The gems to install on all instances
|
150
|
+
# You can install a specific version of a gem by using a sub-array of gem, version
|
151
|
+
# For example, gem: [[rails, 2.2.2], open4, aws-s3]
|
152
|
+
gems: [wr0ngway-rubber, rails, open4, aws-s3]
|
153
|
+
|
154
|
+
# OPTIONAL: A string prepended to shell command strings that cause multi
|
155
|
+
# statement shell commands to fail fast. You may need to comment this out
|
156
|
+
# on some platforms, but it works for me on linux/osx with a bash shell
|
157
|
+
#
|
158
|
+
stop_on_error_cmd: "function error_exit { exit 99; }; trap error_exit ERR"
|
159
|
+
|
160
|
+
# OPTIONAL: The default set of roles to use when creating a staging instance
|
161
|
+
# with "cap rubber:create_staging". By default this uses all the known roles,
|
162
|
+
# but this is not always desired for staging, so you can specify a different
|
163
|
+
# set here
|
164
|
+
#
|
165
|
+
staging_roles: "web,app,db:primary=true"
|
166
|
+
|
167
|
+
|
168
|
+
# OPTIONAL: Lets one assign amazon elastic IPs (static IPs) to your instances
|
169
|
+
# You should typically set this on the role/host level rather than
|
170
|
+
# globally , unless you really do want all instances to have a
|
171
|
+
# static IP
|
172
|
+
#
|
173
|
+
# use_static_ip: true
|
174
|
+
|
175
|
+
# OPTIONAL: Specifies an instance to be created in the given availability zone
|
176
|
+
# Availability zones are sepcified by amazon to be somewhat isolated
|
177
|
+
# from each other so that hardware failures in one zone shouldn't
|
178
|
+
# affect instances in another. As such, it is good to specify these
|
179
|
+
# for instances that need to be redundant to reduce your chance of
|
180
|
+
# downtime. You should typically set this on the role/host level
|
181
|
+
# rather than globally. Use rubber describe:zones to see the list
|
182
|
+
# of zones
|
183
|
+
# availability_zone: us-east-1a
|
184
|
+
|
185
|
+
# OPTIONAL: If you want t use Elastic Block Store (EBS) persistent
|
186
|
+
# volumes, add them to host specific overrides and they will get created
|
187
|
+
# and assigned to the instance. On initial creation, the volume will get
|
188
|
+
# attached _and_ formatted, but if your host disapears and you recreate
|
189
|
+
# it, the volume will only get remounted thereby preserving your data
|
190
|
+
#
|
191
|
+
# hosts:
|
192
|
+
# my_host:
|
193
|
+
# availability_zone: us-east-1a
|
194
|
+
# volumes:
|
195
|
+
# - size: 100 # size of vol in GBs
|
196
|
+
# zone: us-east-1a # zone to create volume in, needs to match host's zone
|
197
|
+
# device: /dev/sdh # OS device to attach volume to
|
198
|
+
# mount: /mnt/mysql # The directory to mount this volume to
|
199
|
+
# filesystem: ext3 # the filesystem to create on volume
|
200
|
+
# - size: 10 # size of vol in GBs
|
201
|
+
# zone: us-east-1a # zone to create volume in, needs to match host's zone
|
202
|
+
# device: /dev/sdi # OS device to attach volume to
|
203
|
+
# mount: /mnt/logs # The directory to mount this volume to
|
204
|
+
# filesystem: ext3 # the filesystem to create on volume
|
205
|
+
#
|
206
|
+
# # volumes without mount/filesystem can be used in raid arrays
|
207
|
+
#
|
208
|
+
# - size: 50 # size of vol in GBs
|
209
|
+
# zone: us-east-1a # zone to create volume in, needs to match host's zone
|
210
|
+
# device: /dev/sdx # OS device to attach volume to
|
211
|
+
# - size: 50 # size of vol in GBs
|
212
|
+
# zone: us-east-1a # zone to create volume in, needs to match host's zone
|
213
|
+
# device: /dev/sdy # OS device to attach volume to
|
214
|
+
#
|
215
|
+
# # for raid array, you'll need to add mdadm to packages. Likewise,
|
216
|
+
# # xfsprogs is needed for xfs filesystem support
|
217
|
+
# packages: [xfsprogs, mdadm]
|
218
|
+
# raid_volumes:
|
219
|
+
# - device: /dev/md0 # OS device to to create raid array on
|
220
|
+
# mount: /mnt/fast # The directory to mount this array to
|
221
|
+
# filesystem: xfs # the filesystem to create on array
|
222
|
+
# raid_level: 0 # the raid level to use for the array
|
223
|
+
# source_devices: [/dev/sdx, /dev/sdy] # the source EBS devices we are creating raid array from
|
224
|
+
|
225
|
+
# OPTIONAL: You can also define your own variables here for use when
|
226
|
+
# transforming config files, and they will be available in your config
|
227
|
+
# templates as <%= rubber_env.var_name %>
|
228
|
+
#
|
229
|
+
# var_name: var_value
|
230
|
+
|
231
|
+
# OPTIONAL: Role specific overrides
|
232
|
+
# roles:
|
233
|
+
# somerole:
|
234
|
+
# packages: []
|
235
|
+
# somerole2:
|
236
|
+
# myconfig: someval
|
237
|
+
|
238
|
+
# OPTIONAL: Host specific overrides
|
239
|
+
# hosts:
|
240
|
+
# somehost:
|
241
|
+
# packages: []
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# rails tries to load this from generator dir, so skip it.
|
2
|
+
if __FILE__ !~ /rubber\/generators\/vulcanize/
|
3
|
+
|
4
|
+
env = ENV['RUBBER_ENV'] ||= (ENV['RAILS_ENV'] || 'development')
|
5
|
+
root = File.dirname(__FILE__) + '/../..'
|
6
|
+
|
7
|
+
# this tries first as a rails plugin then as a gem
|
8
|
+
$:.unshift "#{root}/vendor/plugins/rubber/lib/"
|
9
|
+
require 'rubber'
|
10
|
+
|
11
|
+
Rubber::initialize(root, env)
|
12
|
+
|
13
|
+
require 'rubber/tasks/rubber'
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# For running rake jobs through cron - only prints output if there is an error
|
4
|
+
#
|
5
|
+
# author mconway
|
6
|
+
# since 8/12/07
|
7
|
+
|
8
|
+
RAILS_ROOT = File.expand_path("..", File.dirname(__FILE__))
|
9
|
+
log = "#{RAILS_ROOT}/log/cron-rake-#{Time.now.tv_sec}.log"
|
10
|
+
begin
|
11
|
+
ident = File.basename(ARGV[-1]).gsub(/\W+/, "_")
|
12
|
+
log = "#{RAILS_ROOT}/log/cron-rake-#{ident}.log"
|
13
|
+
rescue
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir.chdir(RAILS_ROOT)
|
17
|
+
args = %W{-l #{log} -- rake --trace} + ARGV
|
18
|
+
system "script/cron-sh", *args
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# For running jobs through cron - only prints output if there is an error
|
4
|
+
#
|
5
|
+
# author mconway
|
6
|
+
# since 8/12/07
|
7
|
+
|
8
|
+
RAILS_ROOT = File.expand_path("..", File.dirname(__FILE__))
|
9
|
+
log = "#{RAILS_ROOT}/log/cron-runner-#{Time.now.tv_sec}.log"
|
10
|
+
begin
|
11
|
+
ident = File.basename(ARGV[-1]).gsub(/\W+/, "_")
|
12
|
+
log = "#{RAILS_ROOT}/log/cron-runner-#{ident}.log"
|
13
|
+
rescue
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir.chdir(RAILS_ROOT)
|
17
|
+
args = %W{-e -l #{log} -- script/runner} + ARGV
|
18
|
+
system "script/cron-sh", *args
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# For running shell commands through cron - only prints output if there is an error
|
4
|
+
#
|
5
|
+
# author mconway
|
6
|
+
# since 8/12/07
|
7
|
+
|
8
|
+
require 'optparse'
|
9
|
+
require 'ostruct'
|
10
|
+
require 'rubygems'
|
11
|
+
require 'open4'
|
12
|
+
|
13
|
+
options = OpenStruct.new
|
14
|
+
options.logfile = "/tmp/cron-sh-#{Time.now.tv_sec}.log"
|
15
|
+
options.echoerr = false
|
16
|
+
options.echoout = false
|
17
|
+
|
18
|
+
opts = OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: cron-sh [options] <shell command>"
|
20
|
+
opts.separator "Runs the given command, sending all stdout/stderr to a logfile, but echoing"
|
21
|
+
opts.separator "the entire file if the command exits with an error"
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Specific options:"
|
24
|
+
|
25
|
+
opts.on("-l", "--log logfile", "Log to given file instead of a default") do |val|
|
26
|
+
options.logfile = val
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-o", "--[no-]echoout", "Log _and_ echo stdout") do |val|
|
30
|
+
options.echoout = true
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-e", "--[no-]echoerr", "Log _and_ echo stderr") do |val|
|
34
|
+
options.echoerr = true
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
cmd = opts.parse(ARGV)
|
44
|
+
|
45
|
+
status = Open4::popen4(*cmd) do |pid, stdin, stdout, stderr|
|
46
|
+
File.open(options.logfile, "w") do | fh |
|
47
|
+
threads = []
|
48
|
+
threads << Thread.new(stdout) do |stdout|
|
49
|
+
stdout.each { |line| $stdout.puts line if options.echoout; fh.print line; fh.flush }
|
50
|
+
end
|
51
|
+
threads << Thread.new(stderr) do |stderr|
|
52
|
+
stderr.each { |line| $stderr.puts line if options.echoerr; fh.print line; fh.flush }
|
53
|
+
end
|
54
|
+
threads.each { |t| t.join }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
result = status.exitstatus
|
59
|
+
if result != 0
|
60
|
+
puts ""
|
61
|
+
puts "*** Process exited with non-zero error code, full output follows"
|
62
|
+
puts "*** Command was: #{cmd.join(' ')}"
|
63
|
+
puts ""
|
64
|
+
puts IO.read(options.logfile)
|
65
|
+
end
|
66
|
+
|
67
|
+
exit(result)
|
@@ -0,0 +1 @@
|
|
1
|
+
description: The core configuration needed by all others
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/etc/haproxy/haproxy.cfg"
|
3
|
+
@additive = ["# start haproxy mongrel", "# end haproxy mongrel"]
|
4
|
+
%>
|
5
|
+
|
6
|
+
listen mongrel_proxy 0.0.0.0:<%= rubber_env.haproxy_listen_port %>
|
7
|
+
<%
|
8
|
+
# Since we do "fair" load balancing to the mongrels, we don't want to share mongrels
|
9
|
+
# between haproxy instances otherwise we still end up with requests getting queued behind
|
10
|
+
# slow ones.
|
11
|
+
mongrel_hosts = rubber_instances.for_role('mongrel').collect { |i| i.name }
|
12
|
+
haproxy_hosts = rubber_instances.for_role('haproxy').collect { |i| i.name }
|
13
|
+
ports = (rubber_env.mongrel_base_port.to_i ... rubber_env.mongrel_base_port.to_i + rubber_env.mongrel_count.to_i).to_a
|
14
|
+
host_count = haproxy_hosts.size
|
15
|
+
host_mod = haproxy_hosts.sort.index(rubber_env.host) rescue 0
|
16
|
+
ports = ports.find_all {|x| x % host_count == host_mod}
|
17
|
+
%>
|
18
|
+
<% mongrel_hosts.each do |server| %>
|
19
|
+
<% ports.each do |port| %>
|
20
|
+
server <%= server %>_<%= port %> <%= server %>:<%= port %> maxconn 1 check
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
|