Created
May 1, 2010 20:46
-
-
Save vitaly/386647 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mix :default | |
mix :utils, :users, :rails, :munin, :monit, :sudoers, :sphinx, :mailserver, :red5 | |
DOMAIN = "example.com" | |
NAME = "production" | |
base_domain DOMAIN | |
base_email "admin" | |
AUTHORIZED = %w/vitaly@sirius-id_dsa.pub/ | |
DB_PASS = "gfdgfdgfd" | |
ROOT_DB_PASS = "kjhkjhkjhkjh" | |
APP_SYSTEM_CONFIG = { | |
:memory_usage => 80, | |
:cpu_system => 20, | |
:cpu_user => 50, | |
:cpu_wait => 50, | |
} | |
DB_SYSTEM_CONFIG = { | |
:memory_usage => 90, | |
:cpu_system => 40, | |
:cpu_user => 80, | |
:cpu_wait => 50, | |
} | |
node :app1, "n123,example.com" do | |
roles :base, :rails, :red5, :munin, :monit, :backup | |
@munin_nodes = [:app1, :db] | |
monit_config :system, APP_SYSTEM_CONFIG | |
end | |
node :db, "n456,example.com" do | |
roles :base, :app, :db, :munin, :monit, :backup | |
monit_config :system, DB_SYSTEM_CONFIG | |
end | |
role :base do | |
# ROOT | |
ssh_key "root", "root@#{current_node}.id_dsa" | |
ssh_auth "root", AUTHORIZED | |
ssh_known_host "root", "github.com-host_key" | |
# ASTRAILS | |
app_user "astrails" | |
ssh_key "astrails", "astrails@#{curernt_node}.id_dsa" | |
ssh_auth "astrails", AUTHORIZED | |
ssh_known_host "astrails", "github.com-host_key" | |
sudoers :delayed_job_users => :astrails | |
# all nodes are polled by app1 | |
munin_node :allow => :app1, :passenger => true, :autoconf => true | |
mysql_user_my_cnf "astrails", DB_PASS, :hostname => hostname(:db) | |
mailserver | |
end | |
role :rails do | |
apache2 :mpm => :prefork | |
passenger | |
monit_config :apache2, :totalmem_restart_mb => 250 | |
# install_sphinx | |
monit_delayed_job :domain => DOMAIN, :environment => "production", :user => "astrails", :group => "astrails" | |
jumppad_gems | |
rails_app "astrails", DOMAIN, :db_prefix => NAME, :db_pass => DB_PASS | |
file "/home/astrails/current", :ensure => "/var/www/#{DOMAIN}/current" | |
file "/home/astrails/#{DOMAIN}", :ensure => "/var/www/#{DOMAIN}" | |
end | |
role :red5 do | |
sun_java6 | |
red5 | |
monit_config "red5" | |
end | |
role :db do | |
mysql_server :root_password => ROOT_DB_PASS | |
mysql_db_grant "#{NAME}", "astrails", "%", DB_PASS | |
end | |
role :monit do | |
monit :server => current_node, :alert => target_email(current_node) | |
end | |
role :munin do | |
munin_cron :nodes => @munin_nodes | |
munin_site :domain => "munin.#{DOMAIN}" | |
end | |
role :backup do | |
astrails_safe({ | |
:keep => {:local => 20, :s3 => 100}, | |
:s3 => {:key => '....', :secret => '...', :bucket => "backup.#{DOMAIN}"}, | |
:gpg => { | |
:password => "...." | |
}}) | |
end | |
# this is not yet 'abstracted out' in full. work in progress. | |
# with time will be just smth like a simple cruise_control_project(...) | |
role :builder do | |
# might need to setup some more gems for the tests to run | |
# gems [ ...] | |
# setup http auth | |
htpasswd("/etc/apache2/auth/#{NAME}", {"user" => "....password..."}, :require => file("/etc/apache2/auth")) | |
dep = cruise_control( | |
:domain => "build.#{DOMAIN}.astrails.com", :name => NAME, | |
:delivery_method => :smtp, | |
:htpasswd => "/etc/apache2/auth/#{NAME}") | |
dep = [ | |
ssh_known_host("cruise_control", "github_com-host_key", :require => dep), | |
ssh_key("cruise_control", "#{NAME}.id_dsa", :require => dep), | |
# grant is independent from the installation. no need to add the dep here | |
mysql_db_grant("#{NAME}_test", "astrails", addr(:app1), DB_PASS), | |
] | |
# add cruise_control.rb project | |
dep = cruise_control_repo(NAME, "git://.....", :require => dep) # we need the known_host to allow git clone | |
# write a database.yml inside the new project dir | |
database_yml( | |
"#{home_dir("cruise_control")}/.cruise/projects/#{NAME}/database.yml", | |
"localhost", "astrails", DB_PASS, {:test => "#{NAME}_test", :development => NAME}, | |
:require => dep, :mode => 0644, :owner => "cruise_control") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment