capitate 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Capfile +24 -0
- data/History.txt +22 -0
- data/License.txt +20 -0
- data/Manifest.txt +100 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/bin/capitate +46 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/capitate/cap_ext/connections.rb +95 -0
- data/lib/capitate/cap_ext/extension_proxy.rb +15 -0
- data/lib/capitate/cap_ext/variables.rb +59 -0
- data/lib/capitate/config.rb +106 -0
- data/lib/capitate/plugins/base.rb +85 -0
- data/lib/capitate/plugins/gem.rb +25 -0
- data/lib/capitate/plugins/package.rb +30 -0
- data/lib/capitate/plugins/profiles.rb +33 -0
- data/lib/capitate/plugins/script.rb +118 -0
- data/lib/capitate/plugins/templates.rb +98 -0
- data/lib/capitate/plugins/wget.rb +23 -0
- data/lib/capitate/plugins/yum.rb +87 -0
- data/lib/capitate/recipes.rb +9 -0
- data/lib/capitate/version.rb +9 -0
- data/lib/capitate.rb +32 -0
- data/lib/doc/centos/memcached.yml +18 -0
- data/lib/doc/centos/mongrel_cluster.yml +11 -0
- data/lib/doc/centos/monit.yml +12 -0
- data/lib/doc/centos/mysql.yml +6 -0
- data/lib/doc/centos/nginx.yml +25 -0
- data/lib/doc/centos/sphinx.yml +14 -0
- data/lib/doc/gems.yml +7 -0
- data/lib/doc/install.yml +11 -0
- data/lib/doc/memcached.yml +13 -0
- data/lib/doc/mongrel_cluster.yml +12 -0
- data/lib/doc/mysql.yml +46 -0
- data/lib/doc/nginx.yml +23 -0
- data/lib/doc/packages.yml +17 -0
- data/lib/doc/rails.yml +15 -0
- data/lib/profiles/centos-sick.rb +114 -0
- data/lib/recipes/README +5 -0
- data/lib/recipes/centos/README +3 -0
- data/lib/recipes/centos/centos.rb +44 -0
- data/lib/recipes/centos/imagemagick.rb +19 -0
- data/lib/recipes/centos/memcached.rb +31 -0
- data/lib/recipes/centos/mongrel_cluster.rb +34 -0
- data/lib/recipes/centos/monit.rb +42 -0
- data/lib/recipes/centos/mysql.rb +25 -0
- data/lib/recipes/centos/nginx.rb +45 -0
- data/lib/recipes/centos/ruby.rb +37 -0
- data/lib/recipes/centos/sphinx.rb +49 -0
- data/lib/recipes/deploy.rb +18 -0
- data/lib/recipes/gems.rb +11 -0
- data/lib/recipes/install.rb +18 -0
- data/lib/recipes/memcached.rb +14 -0
- data/lib/recipes/mongrel_cluster.rb +33 -0
- data/lib/recipes/mysql.rb +33 -0
- data/lib/recipes/nginx.rb +40 -0
- data/lib/recipes/packages.rb +24 -0
- data/lib/recipes/rails.rb +20 -0
- data/lib/recipes/sphinx.rb +38 -0
- data/lib/templates/capistrano/Capfile +26 -0
- data/lib/templates/centos/setup_for_web.sh +17 -0
- data/lib/templates/centos/sudoers +95 -0
- data/lib/templates/memcached/memcached.initd.centos.erb +70 -0
- data/lib/templates/memcached/memcached.monitrc.erb +4 -0
- data/lib/templates/mongrel/mongrel_cluster.initd.erb +61 -0
- data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/templates/monit/cert.sh +14 -0
- data/lib/templates/monit/monit.cnf +34 -0
- data/lib/templates/monit/monit.initd.centos.erb +68 -0
- data/lib/templates/monit/monitrc.erb +28 -0
- data/lib/templates/monit/patch_inittab.sh +15 -0
- data/lib/templates/mysql/install_db.sql.erb +7 -0
- data/lib/templates/mysql/mysql.monitrc.erb +6 -0
- data/lib/templates/nginx/nginx.conf.erb +88 -0
- data/lib/templates/nginx/nginx.initd.erb +62 -0
- data/lib/templates/nginx/nginx.monitrc.erb +4 -0
- data/lib/templates/nginx/nginx_vhost.conf.erb +95 -0
- data/lib/templates/rails/database.yml.erb +42 -0
- data/lib/templates/ruby/fix_openssl.sh +12 -0
- data/lib/templates/sphinx/sphinx.conf.erb +498 -0
- data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +67 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/capitate.rake +10 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_recipes.rb +11 -0
- data/test/test_templates.rb +29 -0
- data/website/index.html +161 -0
- data/website/index.txt +86 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +160 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
install:
|
|
2
|
+
packages_type: |
|
|
3
|
+
Package manager type.
|
|
4
|
+
Currently can only be :yum.
|
|
5
|
+
TODO: Support more package managers.
|
|
6
|
+
|
|
7
|
+
set :packages_type, :yum
|
|
8
|
+
|
|
9
|
+
packages_remove: |
|
|
10
|
+
Packages to remove
|
|
11
|
+
|
|
12
|
+
set :packages_remove, [ "openoffice.org-*", "ImageMagick" ]
|
|
13
|
+
|
|
14
|
+
packages_add: |
|
|
15
|
+
Packages to add.
|
|
16
|
+
|
|
17
|
+
set :packages_add, [ "gcc", "kernel-devel", "libevent-devel", "libxml2-devel" ]
|
data/lib/doc/rails.yml
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This is an EXAMPLE profile.
|
|
3
|
+
#
|
|
4
|
+
# Profile for sick rails app on centos 5.1
|
|
5
|
+
# Profiles are basically a beefed up deploy.rb
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
set :description, "Sick project deployment for centos 5.1 image"
|
|
9
|
+
|
|
10
|
+
#set :install_user, "root"
|
|
11
|
+
|
|
12
|
+
set :recipes, [
|
|
13
|
+
"centos:setup_for_web",
|
|
14
|
+
"packages:install",
|
|
15
|
+
"centos:ruby:install",
|
|
16
|
+
"centos:nginx:install",
|
|
17
|
+
"centos:mysql:install",
|
|
18
|
+
"centos:sphinx:install",
|
|
19
|
+
"centos:monit:install",
|
|
20
|
+
"centos:imagemagick:install",
|
|
21
|
+
"centos:memcached:install",
|
|
22
|
+
"nginx:install_monit",
|
|
23
|
+
"mysql:install_monit",
|
|
24
|
+
"memcached:install_monit",
|
|
25
|
+
"gems:install",
|
|
26
|
+
"centos:cleanup"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Settings for recipes
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
# For packages:install
|
|
34
|
+
set :packages_type, :yum
|
|
35
|
+
set :packages_remove, [ "openoffice.org-*", "ImageMagick" ]
|
|
36
|
+
set :packages_add, [
|
|
37
|
+
"gcc", "kernel-devel", "libevent-devel", "libxml2-devel",
|
|
38
|
+
"openssl", "openssl-devel",
|
|
39
|
+
"aspell", "aspell-devel", "aspell-en", "aspell-es",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
# For gem:install
|
|
43
|
+
set :gem_list, [
|
|
44
|
+
"rake",
|
|
45
|
+
"mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql-config",
|
|
46
|
+
"raspell",
|
|
47
|
+
"rmagick",
|
|
48
|
+
"mongrel",
|
|
49
|
+
"mongrel_cluster",
|
|
50
|
+
"json"
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
# For monit:install
|
|
54
|
+
set :monit_port, 2812 # Capistrano::CLI.ui.ask('Monit port: ')
|
|
55
|
+
set :monit_password, Proc.new { Capistrano::CLI.ui.ask('Monit admin password (to set): ') }
|
|
56
|
+
|
|
57
|
+
# For nginx:install
|
|
58
|
+
set :nginx_bin_path, "/sbin/nginx"
|
|
59
|
+
set :nginx_conf_path, "/etc/nginx/nginx.conf"
|
|
60
|
+
set :nginx_pid_path, "/var/run/nginx.pid"
|
|
61
|
+
set :nginx_prefix_path, "/var/nginx"
|
|
62
|
+
|
|
63
|
+
# For mysql:install
|
|
64
|
+
set :mysql_admin_password_set, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') }
|
|
65
|
+
set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"
|
|
66
|
+
set :db_port, 3306 # Capistrano::CLI.ui.ask('Mysql port: ')
|
|
67
|
+
|
|
68
|
+
# For sphinx:install
|
|
69
|
+
set :sphinx_prefix, "/usr/local/sphinx"
|
|
70
|
+
|
|
71
|
+
# For memcached:install
|
|
72
|
+
set :memcached_pid_path, "/var/run/memcached.pid"
|
|
73
|
+
set :memcached_memory, 64
|
|
74
|
+
set :memcached_port, 11211
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Settings for generating project Capfile
|
|
79
|
+
#
|
|
80
|
+
|
|
81
|
+
set :application, "sick"
|
|
82
|
+
set :user, "sick"
|
|
83
|
+
set :deploy_to, "/var/www/apps/sick"
|
|
84
|
+
set :web_host, "WEB_HOST"
|
|
85
|
+
set :db_host, "DB_HOST"
|
|
86
|
+
set :db_user, "sick"
|
|
87
|
+
set :db_pass, ""
|
|
88
|
+
set :db_name, "sick"
|
|
89
|
+
# db_port set already
|
|
90
|
+
set :sphinx_host, "SPHINX_HOST"
|
|
91
|
+
set :sphinx_port, 3312
|
|
92
|
+
set :repository, "REPOSITORY"
|
|
93
|
+
set :mongrel_port, 12000
|
|
94
|
+
set :mongrel_size, 3
|
|
95
|
+
set :domain_name, "localhost"
|
|
96
|
+
set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') }
|
|
97
|
+
|
|
98
|
+
set :deploy_via, :copy
|
|
99
|
+
set :copy_strategy, :export
|
|
100
|
+
|
|
101
|
+
role :web, "WEB_URL"
|
|
102
|
+
role :db, "DB_URL", :primary => true
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# Callbacks
|
|
106
|
+
before "deploy:setup", "centos:add_user_for_app"
|
|
107
|
+
|
|
108
|
+
after "deploy:setup", "mysql:setup", "rails:setup", "mongrel_cluster:setup_monit",
|
|
109
|
+
"nginx:setup_mongrel", "centos:sphinx:setup"
|
|
110
|
+
|
|
111
|
+
after "deploy:update_code", "rails:update_code", "sphinx:update_code"
|
|
112
|
+
|
|
113
|
+
# Auto cleanup after deploy
|
|
114
|
+
after "deploy", "deploy:cleanup"
|
data/lib/recipes/README
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Custom tasks for centos OS profiles
|
|
2
|
+
namespace :centos do
|
|
3
|
+
|
|
4
|
+
desc "Setup centos for web"
|
|
5
|
+
task :setup_for_web do
|
|
6
|
+
put template.load("centos/sudoers"), "/tmp/sudoers"
|
|
7
|
+
script.sh("centos/setup_for_web.sh")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc "Cleanup"
|
|
11
|
+
task :cleanup do
|
|
12
|
+
yum.clean
|
|
13
|
+
# TODO: Add cleanup tasks here
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Add user for an application
|
|
17
|
+
desc "Add user (adds to admin group)"
|
|
18
|
+
task :add_user_for_app do
|
|
19
|
+
|
|
20
|
+
# Settings
|
|
21
|
+
user = fetch(:user)
|
|
22
|
+
fetch_or_default(:install_user, "root")
|
|
23
|
+
|
|
24
|
+
with_user(install_user) do
|
|
25
|
+
|
|
26
|
+
sudo "id sick || /usr/sbin/adduser -d #{deploy_to} -G admin #{user}"
|
|
27
|
+
sudo "chmod a+rx #{deploy_to}"
|
|
28
|
+
|
|
29
|
+
new_password = Capistrano::CLI.password_prompt("Password for user (#{user}): ")
|
|
30
|
+
|
|
31
|
+
sudo "passwd #{user}" do |channel, stream, data|
|
|
32
|
+
logger.info data
|
|
33
|
+
|
|
34
|
+
if data =~ /password:/i
|
|
35
|
+
channel.send_data "#{new_password}\n"
|
|
36
|
+
channel.send_data "#{new_password}\n"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
namespace :imagemagick do
|
|
3
|
+
|
|
4
|
+
task :install do
|
|
5
|
+
|
|
6
|
+
# Install dependencies
|
|
7
|
+
yum.install([ "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
|
|
8
|
+
"libwmf-devel", "freetype-devel", "libtiff-devel" ])
|
|
9
|
+
|
|
10
|
+
imagemagick_options = {
|
|
11
|
+
:url => "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz",
|
|
12
|
+
:unpack_dir => "ImageMagick-*"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
script.make_install("imagemagick", imagemagick_options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :memcached do
|
|
4
|
+
|
|
5
|
+
desc "Install memcached"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Settings
|
|
9
|
+
fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
|
|
10
|
+
fetch_or_default(:memcached_port, 11211)
|
|
11
|
+
fetch(:memcached_memory)
|
|
12
|
+
|
|
13
|
+
# Build options
|
|
14
|
+
memcached_options = {
|
|
15
|
+
:url => "http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz",
|
|
16
|
+
:configure_options => "--prefix=/usr/local"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Build
|
|
20
|
+
script.make_install("memcached", memcached_options)
|
|
21
|
+
|
|
22
|
+
# Install initscript, service
|
|
23
|
+
put template.load("memcached/memcached.initd.centos.erb"), "/tmp/memcached.initd"
|
|
24
|
+
sudo "install -o root /tmp/memcached.initd /etc/init.d/memcached && rm -f /tmp/memcached.initd"
|
|
25
|
+
sudo "/sbin/chkconfig --level 345 memcached on"
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :mongrel_cluster do
|
|
4
|
+
|
|
5
|
+
after "centos:mongrel_cluster:setup", "mongrel_cluster:setup_monit"
|
|
6
|
+
|
|
7
|
+
desc "Create mongrel cluster"
|
|
8
|
+
task :setup do
|
|
9
|
+
|
|
10
|
+
# Settings
|
|
11
|
+
fetch(:mongrel_size)
|
|
12
|
+
fetch(:mongrel_port)
|
|
13
|
+
|
|
14
|
+
run "mkdir -p #{shared_path}/config"
|
|
15
|
+
|
|
16
|
+
# Mongrel cluster config needs its own config directory
|
|
17
|
+
mongrel_config_path = "#{shared_path}/config/mongrel"
|
|
18
|
+
run "mkdir -p #{mongrel_config_path}"
|
|
19
|
+
|
|
20
|
+
pid_path = "#{shared_path}/pids"
|
|
21
|
+
|
|
22
|
+
put template.load("mongrel/mongrel_cluster.initd.erb", binding), "/tmp/mongrel_cluster_#{application}.initd"
|
|
23
|
+
put template.load("mongrel/mongrel_cluster.yml.erb", binding), "#{mongrel_config_path}/mongrel_cluster.yml"
|
|
24
|
+
|
|
25
|
+
# Setup the mongrel_cluster init script
|
|
26
|
+
sudo "install -o root /tmp/mongrel_cluster_#{application}.initd /etc/init.d/mongrel_cluster_#{application}"
|
|
27
|
+
|
|
28
|
+
sudo "/sbin/chkconfig --level 345 mongrel_cluster_#{application} on"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc "Install monit"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Settings
|
|
9
|
+
fetch_or_default(:monit_port, 2812)
|
|
10
|
+
fetch_or_default(:monit_password,
|
|
11
|
+
Proc.new { Capistrano::CLI.ui.ask('Monit admin password (to set): ') })
|
|
12
|
+
|
|
13
|
+
# Install dependencies
|
|
14
|
+
yum.install([ "flex", "byacc" ])
|
|
15
|
+
|
|
16
|
+
# Build options
|
|
17
|
+
monit_options = {
|
|
18
|
+
:url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Build
|
|
22
|
+
script.make_install("monit", monit_options)
|
|
23
|
+
|
|
24
|
+
# Install initscript
|
|
25
|
+
put template.load("monit/monit.initd.centos.erb"), "/tmp/monit.initd"
|
|
26
|
+
sudo "install -o root /tmp/monit.initd /etc/init.d/monit && rm -f /tmp/monit.initd"
|
|
27
|
+
|
|
28
|
+
# Install monitrc
|
|
29
|
+
put template.load("monit/monitrc.erb"), "/tmp/monitrc"
|
|
30
|
+
sudo "mkdir -p /etc/monit && install -o root -m 700 /tmp/monitrc /etc/monitrc && rm -f /tmp/monitrc"
|
|
31
|
+
|
|
32
|
+
# Patch initab
|
|
33
|
+
script.sh("monit/patch_inittab.sh")
|
|
34
|
+
|
|
35
|
+
# Build cert
|
|
36
|
+
put template.load("monit/monit.cnf"), "/tmp/monit.cnf"
|
|
37
|
+
script.sh("monit/cert.sh")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :mysql do
|
|
4
|
+
|
|
5
|
+
desc "Install mysql"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Settings
|
|
9
|
+
fetch_or_default(:mysql_admin_password_set,
|
|
10
|
+
Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') })
|
|
11
|
+
|
|
12
|
+
# Install through package manager
|
|
13
|
+
yum.install([ "mysql", "mysql-devel", "mysql-server" ])
|
|
14
|
+
|
|
15
|
+
# Install service
|
|
16
|
+
sudo "/sbin/chkconfig --level 345 mysqld on"
|
|
17
|
+
sudo "/sbin/service mysqld start"
|
|
18
|
+
|
|
19
|
+
# Set admin password
|
|
20
|
+
sudo "/usr/bin/mysqladmin -u root password #{mysql_admin_password_set}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :nginx do
|
|
4
|
+
|
|
5
|
+
desc "Install nginx, conf, initscript, nginx user and service"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Settings
|
|
9
|
+
fetch_or_default(:nginx_bin_path, "/sbin/nginx")
|
|
10
|
+
fetch_or_default(:nginx_conf_path, "/etc/nginx/nginx.conf")
|
|
11
|
+
fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
|
|
12
|
+
fetch_or_default(:nginx_prefix_path, "/var/nginx")
|
|
13
|
+
|
|
14
|
+
# Install dependencies
|
|
15
|
+
yum.install([ "pcre-devel", "openssl", "openssl-devel" ])
|
|
16
|
+
|
|
17
|
+
# Build options
|
|
18
|
+
nginx_options = {
|
|
19
|
+
:url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz",
|
|
20
|
+
:configure_options => "--sbin-path=#{nginx_bin_path} --conf-path=#{nginx_conf_path} \
|
|
21
|
+
--pid-path=#{nginx_pid_path} --error-log-path=/var/log/nginx_master_error.log --lock-path=/var/lock/nginx \
|
|
22
|
+
--prefix=#{nginx_prefix_path} --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Build
|
|
26
|
+
script.make_install("nginx", nginx_options)
|
|
27
|
+
|
|
28
|
+
# Install initscript, and turn it on
|
|
29
|
+
put template.load("nginx/nginx.initd.erb"), "/tmp/nginx.initd"
|
|
30
|
+
sudo "install -o root /tmp/nginx.initd /etc/init.d/nginx && rm -f /tmp/nginx.initd"
|
|
31
|
+
sudo "/sbin/chkconfig --level 345 nginx on"
|
|
32
|
+
|
|
33
|
+
# Setup nginx
|
|
34
|
+
sudo "mkdir -p /etc/nginx/vhosts"
|
|
35
|
+
sudo "echo \"# Blank nginx conf; work-around for nginx conf include issue\" > /etc/nginx/vhosts/blank.conf"
|
|
36
|
+
put template.load("nginx/nginx.conf.erb", binding), "/tmp/nginx.conf"
|
|
37
|
+
sudo "install -o root -m 644 /tmp/nginx.conf #{nginx_conf_path} && rm -f /tmp/nginx.conf"
|
|
38
|
+
|
|
39
|
+
# Create nginx user
|
|
40
|
+
sudo "id nginx || /usr/sbin/adduser -r nginx"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :ruby do
|
|
4
|
+
|
|
5
|
+
desc "Install ruby and rubygems"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Install dependencies
|
|
9
|
+
yum.install([ "zlib", "zlib-devel" ])
|
|
10
|
+
|
|
11
|
+
ruby_options = {
|
|
12
|
+
:url => "http://capigen.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz",
|
|
13
|
+
:build_dest => "/usr/src",
|
|
14
|
+
:configure_options => "--prefix=/usr",
|
|
15
|
+
:clean => false
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# Install ruby 1.8.6
|
|
19
|
+
script.make_install("ruby", ruby_options)
|
|
20
|
+
|
|
21
|
+
# Fix openssl
|
|
22
|
+
script.sh("ruby/fix_openssl.sh")
|
|
23
|
+
|
|
24
|
+
rubygems_options = {
|
|
25
|
+
:url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Install rubygems
|
|
29
|
+
script.install("rubygems", rubygems_options) do |dir|
|
|
30
|
+
sudo "echo 'Running setup...' && cd #{dir} && ruby setup.rb > install.log"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
namespace :centos do
|
|
2
|
+
|
|
3
|
+
namespace :sphinx do
|
|
4
|
+
|
|
5
|
+
desc "Install sphinx"
|
|
6
|
+
task :install do
|
|
7
|
+
|
|
8
|
+
# Settings
|
|
9
|
+
fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
|
|
10
|
+
|
|
11
|
+
# Install dependencies
|
|
12
|
+
yum.install([ "gcc-c++" ])
|
|
13
|
+
|
|
14
|
+
# Build options
|
|
15
|
+
sphinx_options = {
|
|
16
|
+
:url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
|
|
17
|
+
:configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql \
|
|
18
|
+
--prefix=#{sphinx_prefix}"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Build
|
|
22
|
+
script.make_install("sphinx", sphinx_options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Setup sphinx for application"
|
|
26
|
+
after "centos:sphinx:setup", "sphinx:setup_monit"
|
|
27
|
+
task :setup do
|
|
28
|
+
|
|
29
|
+
# Settings
|
|
30
|
+
fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
|
|
31
|
+
|
|
32
|
+
# Derived settings
|
|
33
|
+
set :sphinx_bin_path, "#{sphinx_prefix}/bin"
|
|
34
|
+
set :sphinx_conf_path, "#{shared_path}/config/sphinx.conf"
|
|
35
|
+
set :sphinx_pid_path, "#{shared_path}/pids/searchd.pid"
|
|
36
|
+
|
|
37
|
+
# Install initscript
|
|
38
|
+
put template.load("sphinx/sphinx_app.initd.centos.erb"), "/tmp/sphinx.initd"
|
|
39
|
+
sudo "install -o root /tmp/sphinx.initd /etc/init.d/sphinx_#{application}"
|
|
40
|
+
|
|
41
|
+
# Enable service
|
|
42
|
+
sudo "/sbin/chkconfig --level 345 sphinx_#{application} on"
|
|
43
|
+
|
|
44
|
+
# Create app indexes dir
|
|
45
|
+
run "mkdir -p #{shared_path}/var/index"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Override default deploy tasks here (using Monit).
|
|
2
|
+
# If not using monit, use service start/stop:
|
|
3
|
+
# sudo "/sbin/service mongrel_cluster_#{application} restart"
|
|
4
|
+
namespace :deploy do
|
|
5
|
+
|
|
6
|
+
task :restart, :roles => :web do
|
|
7
|
+
sudo "/usr/local/bin/monit -g mongrel_cluster_#{application} restart all"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task :start, :roles => :web do
|
|
11
|
+
sudo "/usr/local/bin/monit -g mongrel_cluster_#{application} start all"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
task :stop, :roles => :web do
|
|
15
|
+
sudo "/usr/local/bin/monit -g mongrel_cluster_#{application} stop all"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
data/lib/recipes/gems.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
namespace :install do
|
|
2
|
+
|
|
3
|
+
task :default do
|
|
4
|
+
|
|
5
|
+
# Settings
|
|
6
|
+
fetch(:recipes)
|
|
7
|
+
fetch_or_default(:install_user, "root")
|
|
8
|
+
|
|
9
|
+
# Change user to install user for this recipes run
|
|
10
|
+
set_user(install_user)
|
|
11
|
+
|
|
12
|
+
# These run after install task and install all the apps
|
|
13
|
+
recipes.each do |task_name|
|
|
14
|
+
after "install", task_name
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
namespace :memcached do
|
|
2
|
+
|
|
3
|
+
desc "Install memcached monit hooks"
|
|
4
|
+
task :install_monit do
|
|
5
|
+
|
|
6
|
+
# Settings
|
|
7
|
+
fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
|
|
8
|
+
fetch_or_default(:memcached_port, 11211)
|
|
9
|
+
|
|
10
|
+
put template.load("memcached/memcached.monitrc.erb", binding), "/tmp/memcached.monitrc"
|
|
11
|
+
sudo "install -o root /tmp/memcached.monitrc /etc/monit/memcached.monitrc"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Create init script
|
|
2
|
+
namespace :mongrel_cluster do
|
|
3
|
+
|
|
4
|
+
desc "Create monit configuration for mongrel cluster"
|
|
5
|
+
task :setup_monit do
|
|
6
|
+
|
|
7
|
+
# See http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/
|
|
8
|
+
|
|
9
|
+
# TODO: For depends on memcached setting
|
|
10
|
+
# See http://blog.labratz.net/articles/2007/5/1/monit-for-your-uptime
|
|
11
|
+
|
|
12
|
+
# Settings
|
|
13
|
+
fetch(:mongrel_size)
|
|
14
|
+
fetch(:mongrel_port)
|
|
15
|
+
|
|
16
|
+
processes = []
|
|
17
|
+
ports = (0...mongrel_size).collect { |i| mongrel_port + i }
|
|
18
|
+
ports.each do |port|
|
|
19
|
+
|
|
20
|
+
pid_path = "#{shared_path}/pids/mongrel.#{port}.pid"
|
|
21
|
+
start_options = "-d -e production -a 127.0.0.1 -c #{current_path} --user #{user} --group #{user} -p #{port} -P #{pid_path} -l log/mongrel.#{port}.log"
|
|
22
|
+
stop_options = "-p #{port} -P #{pid_path}"
|
|
23
|
+
|
|
24
|
+
processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => "/usr/bin/mongrel_rails", :pid_path => pid_path }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
set :processes, processes
|
|
28
|
+
|
|
29
|
+
put template.load("mongrel/mongrel_cluster.monitrc.erb"), "/tmp/mongrel_cluster_#{application}.monitrc"
|
|
30
|
+
sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc /etc/monit/mongrel_cluster_#{application}.monitrc"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Mysql recipes
|
|
2
|
+
namespace :mysql do
|
|
3
|
+
|
|
4
|
+
desc "Install mysql monit hooks"
|
|
5
|
+
task :install_monit do
|
|
6
|
+
|
|
7
|
+
# Settings
|
|
8
|
+
fetch_or_default(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
|
|
9
|
+
fetch_or_default(:db_port, 3306)
|
|
10
|
+
|
|
11
|
+
put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
|
|
12
|
+
sudo "install -o root /tmp/mysql.monitrc /etc/monit/mysql.monitrc"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Create database user, and database with appropriate permissions"
|
|
16
|
+
task :setup do
|
|
17
|
+
|
|
18
|
+
# Settings
|
|
19
|
+
fetch(:db_name)
|
|
20
|
+
fetch(:db_user)
|
|
21
|
+
fetch(:db_pass)
|
|
22
|
+
fetch(:db_host)
|
|
23
|
+
fetch_or_default(:mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') })
|
|
24
|
+
fetch_or_default(:web_host, nil)
|
|
25
|
+
|
|
26
|
+
# Add localhost to grant locations
|
|
27
|
+
set :locations_for_grant, [ "localhost", web_host, db_host ].compact
|
|
28
|
+
|
|
29
|
+
put template.load("mysql/install_db.sql.erb"), "/tmp/install_db_#{application}.sql"
|
|
30
|
+
run "mysql -u root -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Nginx recipes
|
|
2
|
+
namespace :nginx do
|
|
3
|
+
|
|
4
|
+
# Callbacks
|
|
5
|
+
after "nginx:setup", "nginx:restart"
|
|
6
|
+
|
|
7
|
+
desc "Install nginx monit hooks"
|
|
8
|
+
task :install_monit do
|
|
9
|
+
|
|
10
|
+
# Settings
|
|
11
|
+
fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
|
|
12
|
+
|
|
13
|
+
put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
|
|
14
|
+
sudo "install -o root /tmp/nginx.monitrc /etc/monit/nginx.monitrc"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Create and update the nginx vhost include"
|
|
18
|
+
task :setup_mongrel do
|
|
19
|
+
|
|
20
|
+
# Settings
|
|
21
|
+
fetch(:mongrel_size)
|
|
22
|
+
fetch(:mongrel_port)
|
|
23
|
+
fetch(:domain_name)
|
|
24
|
+
|
|
25
|
+
set :ports, (0...mongrel_size).collect { |i| mongrel_port + i }
|
|
26
|
+
set :public_path, current_path + "/public"
|
|
27
|
+
|
|
28
|
+
run "mkdir -p #{shared_path}/config"
|
|
29
|
+
put template.load("nginx/nginx_vhost.conf.erb"), "/tmp/nginx_#{application}.conf"
|
|
30
|
+
|
|
31
|
+
sudo "install -o root /tmp/nginx_#{application}.conf /etc/nginx/vhosts/#{application}.conf"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Restart nginx
|
|
35
|
+
task :restart do
|
|
36
|
+
# TODO: Monit
|
|
37
|
+
sudo "/sbin/service nginx restart"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|