centostrano 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +215 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +166 -0
- data/THANKS +5 -0
- data/bin/centify +137 -0
- data/docs/ANNOUNCE.deprec2 +47 -0
- data/docs/README.install +88 -0
- data/docs/README.nagios +28 -0
- data/docs/README.rails +20 -0
- data/docs/README.svn +31 -0
- data/docs/ROADMAP.txt +74 -0
- data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
- data/docs/deprec-1.x/notes.txt +12 -0
- data/docs/deprec_banner.gif +0 -0
- data/lib/centostrano.rb +9 -0
- data/lib/deprec/capistrano_extensions.rb +391 -0
- data/lib/deprec/centostrano.rb +46 -0
- data/lib/deprec/recipes/apache.rb +188 -0
- data/lib/deprec/recipes/canonical.rb +57 -0
- data/lib/deprec/recipes/deprec.rb +188 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +106 -0
- data/lib/deprec/recipes/gitosis.rb +134 -0
- data/lib/deprec/recipes/logrotate.rb +54 -0
- data/lib/deprec/recipes/memcache.rb +53 -0
- data/lib/deprec/recipes/merb.rb +57 -0
- data/lib/deprec/recipes/mongrel.rb +220 -0
- data/lib/deprec/recipes/monit.rb +139 -0
- data/lib/deprec/recipes/mysql.rb +147 -0
- data/lib/deprec/recipes/nginx.rb +172 -0
- data/lib/deprec/recipes/postgresql.rb +132 -0
- data/lib/deprec/recipes/rails.rb +297 -0
- data/lib/deprec/recipes/ruby.rb +71 -0
- data/lib/deprec/recipes/sphinx.rb +89 -0
- data/lib/deprec/recipes/ssh.rb +93 -0
- data/lib/deprec/recipes/svn.rb +167 -0
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes.rb +33 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
- data/lib/deprec/templates/apache/httpd.conf +465 -0
- data/lib/deprec/templates/apache/index.html.erb +37 -0
- data/lib/deprec/templates/apache/master.css +72 -0
- data/lib/deprec/templates/centos/repository.erb +6 -0
- data/lib/deprec/templates/coraid/aoe-init +55 -0
- data/lib/deprec/templates/deprec/caprc.erb +14 -0
- data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
- data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
- data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
- data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/templates/mongrel/logrotate.erb +0 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
- data/lib/deprec/templates/monit/monit-init-script +104 -0
- data/lib/deprec/templates/monit/monitrc.erb +227 -0
- data/lib/deprec/templates/monit/nothing +0 -0
- data/lib/deprec/templates/mysql/create_databases.sql +20 -0
- data/lib/deprec/templates/mysql/database.yml.prod +6 -0
- data/lib/deprec/templates/mysql/database.yml.stage +6 -0
- data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
- data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
- data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
- data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
- data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
- data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
- data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
- data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
- data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
- data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
- data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
- data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
- data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
- data/lib/deprec/templates/network/hostname.erb +1 -0
- data/lib/deprec/templates/network/hosts.erb +2 -0
- data/lib/deprec/templates/network/interfaces.erb +22 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/logrotate.erb +0 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +109 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +120 -0
- data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
- data/lib/deprec/templates/nginx/nothing.conf +1 -0
- data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
- data/lib/deprec/templates/postfix/aliases.erb +3 -0
- data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
- data/lib/deprec/templates/postfix/main.cf.erb +41 -0
- data/lib/deprec/templates/postfix/master.cf.erb +77 -0
- data/lib/deprec/templates/postgresql/pg_hba.conf.erb +76 -0
- data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
- data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
- data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
- data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
- data/lib/deprec/templates/trac/trac.ini.erb +106 -0
- data/lib/deprec/templates/trac/trac_deprec.png +0 -0
- data/lib/deprec/templates/trac/tracd-init.erb +43 -0
- data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +69 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
- data/lib/deprec_cmd_completion.sh +26 -0
- data/lib/vmbuilder_plugins/all.rb +20 -0
- data/lib/vmbuilder_plugins/apt.rb +93 -0
- data/lib/vmbuilder_plugins/emerge.rb +76 -0
- data/lib/vmbuilder_plugins/gem.rb +90 -0
- data/lib/vmbuilder_plugins/std.rb +203 -0
- metadata +207 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2008 by Saulius Grigaitis. All rights reserved.
|
2
|
+
require 'capistrano'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Yum
|
6
|
+
|
7
|
+
def enable_repository(name)
|
8
|
+
case name
|
9
|
+
when :rpmforge
|
10
|
+
rpm_install("http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.`uname -i`.rpm")
|
11
|
+
when :epel
|
12
|
+
sudo "sudo test -f /etc/yum.repos.d/epel.repo || sudo rpm -U http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def rpm_install(packages, options={})
|
17
|
+
send(run_method, "wget -Ncq #{[*packages].join(' ')}", options)
|
18
|
+
files=[*packages].collect { |package| File.basename(package) }
|
19
|
+
# TODO hmm... This should me replaces with something more smart, like check if package is already installed
|
20
|
+
send(run_method, "rpm -U --force #{files.join(' ')}", options)
|
21
|
+
send(run_method, "rm #{files.join(' ')}", options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def install_from_src(src_package, src_dir)
|
25
|
+
package_dir = File.join(src_dir, src_package[:dir])
|
26
|
+
deprec2.unpack_src(src_package, src_dir)
|
27
|
+
enable_repository :rpmforge
|
28
|
+
enable_repository :epel
|
29
|
+
rpm_install("http://www.asic-linux.com.mx/~izto/checkinstall/files/rpm/checkinstall-1.6.1-1.i386.rpm")
|
30
|
+
apt.install( {:base => %w(gcc gcc-c++ make patch rpm-build which)}, :stable )
|
31
|
+
# XXX replace with invoke_command
|
32
|
+
sudo <<-SUDO
|
33
|
+
sh -c '
|
34
|
+
cd #{package_dir};
|
35
|
+
#{src_package[:configure]}
|
36
|
+
#{src_package[:make]}
|
37
|
+
sudo /usr/local/sbin/checkinstall -y -R --install --pkgversion=#{src_package[:version]} --pkgrelease=#{src_package[:release]} #{src_package[:install]}
|
38
|
+
#{src_package[:post_install]}
|
39
|
+
'
|
40
|
+
SUDO
|
41
|
+
#/usr/local/sbin/checkinstall --fstrans=no -y -R #{src_package[:install]}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
Capistrano.plugin :yum, Yum
|
@@ -0,0 +1,188 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :centos do
|
4
|
+
namespace :apache do
|
5
|
+
|
6
|
+
# put apache config for site in shared/config/apache2 dir
|
7
|
+
# link it into apps to enable, unlink to disable?
|
8
|
+
# http://times.usefulinc.com/2006/09/15-rails-debian-apache
|
9
|
+
|
10
|
+
# XXX Check this over after a nice sleep
|
11
|
+
#
|
12
|
+
# def set_apache_conf
|
13
|
+
# if apache_default_vhost
|
14
|
+
# set :apache_conf, "/usr/local/apache2/conf/default.conf" unless apache_default_vhost_conf
|
15
|
+
# else
|
16
|
+
# set :apache_conf, "/usr/local/apache2/conf/apps/#{application}.conf" unless apache_conf
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
|
20
|
+
set(:apache_server_name) { domain }
|
21
|
+
set :apache_user, 'daemon' # XXX this is not yet being inserted into httpd.conf!
|
22
|
+
# I've added it for deprec:nagios:install
|
23
|
+
set :apache_conf, nil
|
24
|
+
set :apache_default_vhost, false
|
25
|
+
set :apache_default_vhost_conf, nil
|
26
|
+
set :apache_ctl, "/etc/init.d/httpd"
|
27
|
+
set(:apache_server_aliases) { web_server_aliases }
|
28
|
+
set :apache_proxy_port, 8000
|
29
|
+
set :apache_proxy_servers, 2
|
30
|
+
set :apache_proxy_address, "127.0.0.1"
|
31
|
+
set :apache_ssl_enabled, false
|
32
|
+
set :apache_ssl_ip, nil
|
33
|
+
set :apache_ssl_forward_all, false
|
34
|
+
set :apache_ssl_chainfile, false
|
35
|
+
set :apache_docroot, '/usr/local/apache2/htdocs'
|
36
|
+
set :apache_vhost_dir, '/usr/local/apache2/conf/apps'
|
37
|
+
set :apache_config_file, '/usr/local/apache2/conf/httpd.conf'
|
38
|
+
|
39
|
+
|
40
|
+
SRC_PACKAGES[:apache] = {
|
41
|
+
:filename => 'httpd-2.2.9.tar.gz',
|
42
|
+
:md5sum => "28470617033b8fb998779f6d76016f82 httpd-2.2.9.tar.gz",
|
43
|
+
:dir => 'httpd-2.2.9',
|
44
|
+
:url => "http://www.apache.org/dist/httpd/httpd-2.2.9.tar.gz",
|
45
|
+
:unpack => "tar zxf httpd-2.2.9.tar.gz;",
|
46
|
+
:configure => %w(
|
47
|
+
./configure
|
48
|
+
--enable-mods-shared=all
|
49
|
+
--enable-proxy
|
50
|
+
--enable-proxy-balancer
|
51
|
+
--enable-proxy-http
|
52
|
+
--enable-rewrite
|
53
|
+
--enable-cache
|
54
|
+
--enable-headers
|
55
|
+
--enable-ssl
|
56
|
+
--enable-deflate
|
57
|
+
--with-included-apr #_so_this_recipe_doesn't_break_when_rerun
|
58
|
+
--enable-dav #_for_subversion_
|
59
|
+
--enable-so #_for_subversion_
|
60
|
+
;
|
61
|
+
).reject{|arg| arg.match '#'}.join(' '),
|
62
|
+
:make => 'make;',
|
63
|
+
:install => '--fstrans=no make install;',
|
64
|
+
:post_install => 'install -b support/apachectl /etc/init.d/httpd;',
|
65
|
+
:version => 'c2.2.9',
|
66
|
+
:release => '1'
|
67
|
+
}
|
68
|
+
|
69
|
+
desc "Install apache"
|
70
|
+
task :install do
|
71
|
+
install_deps
|
72
|
+
sudo "yum remove -y httpd"
|
73
|
+
deprec2.download_src(SRC_PACKAGES[:apache], src_dir)
|
74
|
+
yum.install_from_src(SRC_PACKAGES[:apache], src_dir)
|
75
|
+
setup_vhost_dir
|
76
|
+
# install_index_page
|
77
|
+
activate
|
78
|
+
SYSTEM_CONFIG_FILES[:apache].each do |file|
|
79
|
+
deprec2.render_template(:apache, file.merge(:remote => true))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# install dependencies for apache
|
84
|
+
task :install_deps do
|
85
|
+
apt.install( {:base => %w(zlib1g-dev zlib1g openssl openssl-devel)}, :stable )
|
86
|
+
end
|
87
|
+
|
88
|
+
# Create dir for vhost config files
|
89
|
+
task :setup_vhost_dir do
|
90
|
+
deprec2.mkdir(apache_vhost_dir, :owner => 'root', :group => group, :mode => 0775, :via => :sudo)
|
91
|
+
deprec2.append_to_file_if_missing(apache_config_file, 'Include conf/apps/')
|
92
|
+
end
|
93
|
+
|
94
|
+
SYSTEM_CONFIG_FILES[:apache] = [
|
95
|
+
# They're generated and put in place during install
|
96
|
+
# I may put them in here at some point
|
97
|
+
]
|
98
|
+
|
99
|
+
PROJECT_CONFIG_FILES[:apache] = [
|
100
|
+
|
101
|
+
{:template => "httpd-vhost-app.conf.erb",
|
102
|
+
:path => 'conf/httpd-vhost-app.conf',
|
103
|
+
:mode => 0755,
|
104
|
+
:owner => 'root:root'}
|
105
|
+
]
|
106
|
+
|
107
|
+
desc "Generate configuration file(s) for apache from template(s)"
|
108
|
+
task :config_gen do
|
109
|
+
config_gen_system
|
110
|
+
config_gen_project
|
111
|
+
end
|
112
|
+
|
113
|
+
task :config_gen_system do
|
114
|
+
SYSTEM_CONFIG_FILES[:apache].each do |file|
|
115
|
+
deprec2.render_template(:apache, file)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
task :config_gen_project do
|
120
|
+
PROJECT_CONFIG_FILES[:apache].each do |file|
|
121
|
+
deprec2.render_template(:apache, file)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "Push apache config files to server"
|
126
|
+
task :config, :roles => :web do
|
127
|
+
config_system
|
128
|
+
config_project
|
129
|
+
end
|
130
|
+
|
131
|
+
task :config_system, :roles => :web do
|
132
|
+
deprec2.push_configs(:apache, SYSTEM_CONFIG_FILES[:apache])
|
133
|
+
end
|
134
|
+
|
135
|
+
task :config_project, :roles => :web do
|
136
|
+
deprec2.push_configs(:apache, PROJECT_CONFIG_FILES[:apache])
|
137
|
+
sudo "ln -sf #{deploy_to}/apache/conf/httpd-vhost-app.conf /usr/local/apache2/conf/apps/#{application}.conf"
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Start Apache"
|
141
|
+
task :start, :roles => :web do
|
142
|
+
send(run_method, "#{apache_ctl} start")
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "Stop Apache"
|
146
|
+
task :stop, :roles => :web do
|
147
|
+
send(run_method, "#{apache_ctl} stop")
|
148
|
+
end
|
149
|
+
|
150
|
+
desc "Restart Apache"
|
151
|
+
task :restart, :roles => :web do
|
152
|
+
send(run_method, "#{apache_ctl} restart")
|
153
|
+
end
|
154
|
+
|
155
|
+
desc "Reload Apache"
|
156
|
+
task :reload, :roles => :web do
|
157
|
+
send(run_method, "#{apache_ctl} reload")
|
158
|
+
end
|
159
|
+
|
160
|
+
desc "Set apache to start on boot"
|
161
|
+
task :activate do
|
162
|
+
send(run_method, "/sbin/chkconfig --add httpd")
|
163
|
+
send(run_method, "/sbin/chkconfig --level 345 httpd on")
|
164
|
+
end
|
165
|
+
|
166
|
+
desc "Set apache to not start on boot"
|
167
|
+
task :deactivate, :roles => :web do
|
168
|
+
send(run_method, "/sbin/chkconfig --del httpd")
|
169
|
+
end
|
170
|
+
|
171
|
+
task :backup, :roles => :web do
|
172
|
+
# not yet implemented
|
173
|
+
end
|
174
|
+
|
175
|
+
task :restore, :roles => :web do
|
176
|
+
# not yet implemented
|
177
|
+
end
|
178
|
+
|
179
|
+
# Generate an index.html page
|
180
|
+
task :install_index_page do
|
181
|
+
deprec2.mkdir(apache_docroot, :owner => :root, :group => :deploy, :mode => 0775, :via => :sudo)
|
182
|
+
std.su_put deprec2.render_template(:apache, :template => 'index.html.erb'), File.join(apache_docroot, 'index.html')
|
183
|
+
std.su_put deprec2.render_template(:apache, :template => 'master.css'), File.join(apache_docroot, 'master.css')
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
# canonical.rb
|
3
|
+
#
|
4
|
+
# Running deprec:web:stop will be the same as running deprec:apache:stop or
|
5
|
+
# deprec:nginx:stop depending what you have chosen.
|
6
|
+
#
|
7
|
+
# generic namespaces are linked up to chosen applications at runtime but these
|
8
|
+
# stubs are so they'll be included in the output of "cap -T"
|
9
|
+
#
|
10
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
11
|
+
|
12
|
+
%w(web app db).each do |server|
|
13
|
+
namespace "deprec:#{server}" do
|
14
|
+
|
15
|
+
desc "Install #{server} server"
|
16
|
+
task :install, :roles => server do
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Generate config file(s) for #{server} server from template(s)"
|
20
|
+
task :config_gen do
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Deploy configuration files(s) for #{server} server"
|
24
|
+
task :config, :roles => server do
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Start #{server} server"
|
28
|
+
task :start, :roles => server do
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Stop #{server} server"
|
32
|
+
task :stop, :roles => server do
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Stop #{server} server"
|
36
|
+
task :restart, :roles => server do
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Enable startup script for #{server} server"
|
40
|
+
task :activate, :roles => server do
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Disable startup script for #{server} server"
|
44
|
+
task :deactivate, :roles => server do
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Backup data for #{server} server"
|
48
|
+
task :backup, :roles => server do
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Restore data for #{server} server from backup"
|
52
|
+
task :restore, :roles => server do
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
|
4
|
+
# Set the value if not already set
|
5
|
+
# This method is accessible to all recipe files
|
6
|
+
def self.default(name, *args, &block)
|
7
|
+
unless exists?(name)
|
8
|
+
set(name, *args, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Deprec checks here for local versions of config templates before it's own
|
13
|
+
set :local_template_dir, File.join('config','templates')
|
14
|
+
|
15
|
+
# The following two Constants contain details of the configuration
|
16
|
+
# files used by each service. They're used when generating config
|
17
|
+
# files from templates and when configs files are pushed out to servers.
|
18
|
+
#
|
19
|
+
# They are populated by the recipe file for each service
|
20
|
+
#
|
21
|
+
SYSTEM_CONFIG_FILES = {} # e.g. httpd.conf
|
22
|
+
PROJECT_CONFIG_FILES = {} # e.g. projectname-httpd-vhost.conf
|
23
|
+
|
24
|
+
# For each service, the details of the file to download and options
|
25
|
+
# to configure, build and install the service
|
26
|
+
SRC_PACKAGES = {} unless defined?(SRC_PACKAGES)
|
27
|
+
|
28
|
+
# Server options
|
29
|
+
CHOICES_WEBSERVER = [:nginx, :apache, :none]
|
30
|
+
CHOICES_APPSERVER = [:mongrel, :webrick, :none]
|
31
|
+
CHOICES_DATABASE = [:mysql, :postgres, :none]
|
32
|
+
|
33
|
+
|
34
|
+
# Server defaults
|
35
|
+
default :web_server_type, :apache
|
36
|
+
default :app_server_type, :mongrel
|
37
|
+
default :db_server_type, :mysql
|
38
|
+
|
39
|
+
default(:web_server_type) do
|
40
|
+
Capistrano::CLI.ui.choose do |menu|
|
41
|
+
CHOICES_WEBSERVER.each {|c| menu.choice(c)}
|
42
|
+
menu.header = "select webserver type"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
default(:app_server_type) do
|
47
|
+
Capistrano::CLI.ui.choose do |menu|
|
48
|
+
CHOICES_APPSERVER.each {|c| menu.choice(c)}
|
49
|
+
menu.header = "select application server type"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
default(:db_server_type) do
|
54
|
+
Capistrano::CLI.ui.choose do |menu|
|
55
|
+
CHOICES_DATABASE.each {|c| menu.choice(c)}
|
56
|
+
menu.header = "select database server type"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
default(:application) do
|
61
|
+
Capistrano::CLI.ui.ask "enter name of project(no spaces)" do |q|
|
62
|
+
q.validate = /^[0-9a-z_]*$/
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
default(:domain) do
|
67
|
+
Capistrano::CLI.ui.ask "enter domain name for project" do |q|
|
68
|
+
q.validate = /^[0-9a-z_\.]*$/
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
default(:repository) do
|
73
|
+
Capistrano::CLI.ui.ask "enter repository URL for project" do |q|
|
74
|
+
# q.validate = //
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# some tasks run commands requiring special user privileges on remote servers
|
79
|
+
# these tasks will run the commands with:
|
80
|
+
# :invoke_command "command", :via => run_method
|
81
|
+
# override this value if sudo is not an option
|
82
|
+
# in that case, your use will need the correct privileges
|
83
|
+
default :run_method, :sudo
|
84
|
+
|
85
|
+
default(:backup_dir) { '/var/backups'}
|
86
|
+
|
87
|
+
# XXX rails deploy stuff
|
88
|
+
set :apps_root, File.join( %w(/ opt apps) ) # parent dir for apps
|
89
|
+
default(:deploy_to) { File.join(apps_root, application) } # dir for current app
|
90
|
+
default(:current_path) { File.join(deploy_to, "current") }
|
91
|
+
default(:shared_path) { File.join(deploy_to, "shared") }
|
92
|
+
|
93
|
+
# XXX more rails deploy stuff?
|
94
|
+
|
95
|
+
default :user, ENV['USER'] # user who is deploying
|
96
|
+
default :group, 'deploy' # deployment group
|
97
|
+
default(:group_src) { group } # group ownership for src dir
|
98
|
+
default :src_dir, '/usr/local/src' # 3rd party src on servers lives here
|
99
|
+
default(:web_server_aliases) { domain.match(/^www/) ? [] : ["www.#{domain}"] }
|
100
|
+
|
101
|
+
# XXX for some reason this is causing "before deprec:rails:install" to be executed twice
|
102
|
+
# on :load, 'deprec:connect_canonical_tasks'
|
103
|
+
|
104
|
+
namespace :centos do
|
105
|
+
|
106
|
+
task :connect_canonical_tasks, :hosts => 'localhost' do
|
107
|
+
# link application specific recipes into canonical task names
|
108
|
+
# e.g. deprec:web:restart => deprec:nginx:restart
|
109
|
+
metaclass = class << self; self; end
|
110
|
+
[:web, :app, :db].each do |server|
|
111
|
+
server_type = send("#{server}_server_type")
|
112
|
+
if server_type != :none
|
113
|
+
metaclass.send(:define_method, server) { namespaces[server] }
|
114
|
+
self.namespaces[server] = deprec.send(server_type)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
task :dump do
|
120
|
+
require 'yaml'
|
121
|
+
y variables
|
122
|
+
end
|
123
|
+
|
124
|
+
task :setup_src_dir do
|
125
|
+
deprec2.groupadd(group_src)
|
126
|
+
deprec2.add_user_to_group(user, group_src)
|
127
|
+
deprec2.create_src_dir
|
128
|
+
end
|
129
|
+
|
130
|
+
# Download all packages used by deprec to your local host.
|
131
|
+
# You can then push them to /usr/local/src on target hosts
|
132
|
+
# to save time and bandwidth rather than repeatedly downloading
|
133
|
+
# from the distribution sites.
|
134
|
+
task :update_src do
|
135
|
+
SRC_PACKAGES.each{|key, src_package|
|
136
|
+
current_dir = Dir.pwd
|
137
|
+
system "cd src/ && test -f #{src_package[:filename]} || wget --quiet --timestamping #{src_package[:url]}"
|
138
|
+
system "cd #{current_dir}"
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
# todo
|
143
|
+
#
|
144
|
+
# Copy files from src/ to /usr/local/src/ on remote hosts
|
145
|
+
task :push_src do
|
146
|
+
SRC_PACKAGES.each do |key, src_package|
|
147
|
+
deprec2.set_package_defaults(src_package)
|
148
|
+
file = File.join('src', src_package[:filename])
|
149
|
+
if File.exists?(file)
|
150
|
+
std.su_put(File.read(file), "#{src_dir}/#{src_package[:filename]}", '/tmp/')
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
task :list_src do
|
156
|
+
# XXX ugly line - look away
|
157
|
+
max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
|
158
|
+
SRC_PACKAGES.each{|key, src_package|
|
159
|
+
deprec2.set_package_defaults(src_package)
|
160
|
+
puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
task :find_src do
|
165
|
+
# XXX ugly line - look away
|
166
|
+
max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
|
167
|
+
SRC_PACKAGES.each{|key, src_package|
|
168
|
+
deprec2.set_package_defaults(src_package)
|
169
|
+
puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
|
170
|
+
puts `find . -name #{src_package[:filename]}`
|
171
|
+
puts
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
task :recover_src do
|
176
|
+
# XXX ugly line - look away
|
177
|
+
max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
|
178
|
+
SRC_PACKAGES.each{|key, src_package|
|
179
|
+
puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
|
180
|
+
file = `find . -name #{src_package[:filename]}`.split[0]
|
181
|
+
`cp #{file} src/` if file
|
182
|
+
puts
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|