deprec 1.9.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +280 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +152 -0
- data/THANKS +17 -0
- data/bin/depify +128 -0
- data/docs/EXAMPLE-installing_tracks.txt +41 -0
- data/docs/README.nagios +22 -0
- data/docs/README.rails +17 -0
- data/docs/config_gen_explained.txt +39 -0
- data/docs/{README.quickstart → deprec-1.x/deprec-1.x.quickstart} +4 -1
- data/docs/{building_edge_capistrano.txt → deprec-1.x/notes.txt} +6 -3
- data/docs/old/deprec_banner.gif +0 -0
- data/docs/windows_linux.txt +350 -0
- data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
- data/docs/xen/xen-tools-notes.txt +31 -0
- data/docs/xen/xen_on_hardy.txt +39 -0
- data/lib/deprec.rb +8 -1
- data/lib/deprec/capistrano_extensions.rb +442 -0
- data/lib/deprec/recipes.rb +50 -233
- data/lib/deprec/recipes/aoe.rb +79 -0
- data/lib/deprec/recipes/app/mongrel.rb +213 -0
- data/lib/deprec/recipes/app/passenger.rb +197 -0
- data/lib/deprec/recipes/apt_mirror.rb +99 -0
- data/lib/deprec/recipes/ar_sendmail.rb +67 -0
- data/lib/deprec/recipes/canonical.rb +68 -0
- data/lib/deprec/recipes/db/mysql.rb +144 -0
- data/lib/deprec/recipes/db/postgresql.rb +104 -0
- data/lib/deprec/recipes/db/sqlite.rb +37 -0
- data/lib/deprec/recipes/ddclient.rb +51 -0
- data/lib/deprec/recipes/deprec.rb +199 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +97 -0
- data/lib/deprec/recipes/gitosis.rb +48 -0
- data/lib/deprec/recipes/heartbeat.rb +138 -0
- data/lib/deprec/recipes/logrotate.rb +54 -0
- data/lib/deprec/recipes/lvm.rb +20 -0
- data/lib/deprec/recipes/memcache.rb +6 -2
- data/lib/deprec/recipes/monit.rb +143 -0
- data/lib/deprec/recipes/nagios.rb +305 -0
- data/lib/deprec/recipes/network.rb +93 -0
- data/lib/deprec/recipes/ntp.rb +103 -0
- data/lib/deprec/recipes/php.rb +58 -0
- data/lib/deprec/recipes/postfix.rb +115 -0
- data/lib/deprec/recipes/rails.rb +300 -55
- data/lib/deprec/recipes/ruby/mri.rb +55 -0
- data/lib/deprec/recipes/ruby/ree.rb +41 -0
- data/lib/deprec/recipes/sphinx.rb +86 -0
- data/lib/deprec/recipes/ssh.rb +85 -18
- data/lib/deprec/recipes/ssl.rb +55 -0
- data/lib/deprec/recipes/starling.rb +119 -0
- data/lib/deprec/recipes/svn.rb +163 -183
- data/lib/deprec/recipes/trac.rb +239 -62
- data/lib/deprec/recipes/ubuntu.rb +18 -100
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes/utils.rb +58 -0
- data/lib/deprec/recipes/vnstat.rb +85 -0
- data/lib/deprec/recipes/web/apache.rb +119 -0
- data/lib/deprec/recipes/web/nginx.rb +172 -0
- data/lib/deprec/recipes/wordpress.rb +96 -0
- data/lib/deprec/recipes/wpmu.rb +103 -0
- data/lib/deprec/recipes/xen.rb +267 -0
- data/lib/deprec/recipes/xentools.rb +75 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
- data/lib/deprec/templates/apt/sources.list +18 -0
- data/lib/deprec/templates/apt_mirror/apt-mirror-cron +4 -0
- data/lib/deprec/templates/apt_mirror/mirror.list +33 -0
- data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
- data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
- data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
- data/lib/deprec/templates/ddclient/ddclient.erb +15 -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/apache_vhost.erb +148 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/{third_party/mongrel_cluster/resources/mongrel_cluster → templates/mongrel/mongrel_cluster-init-script} +19 -6
- 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/mongrel/nginx_vhost.erb +41 -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/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -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 +18 -0
- data/lib/deprec/templates/network/resolv.conf.erb +6 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +62 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +125 -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/passenger/apache_vhost.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.load.erb +3 -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.conf → postfix/main.cf.erb} +6 -8
- data/lib/deprec/templates/postfix/master.cf.erb +77 -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/ssl/make-ssl-cert +138 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
- data/lib/deprec/templates/starling/monit.conf.erb +14 -0
- data/lib/deprec/templates/starling/starling-init-script.erb +71 -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/nginx_vhost.conf.erb +26 -0
- data/lib/deprec/templates/trac/trac.ini.erb +169 -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/trac/users.htdigest.erb +0 -0
- data/lib/deprec/templates/vnstat/config.php +57 -0
- data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
- data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
- data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +57 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xentools/40-setup-networking +145 -0
- data/lib/deprec/templates/xentools/xen-tools.conf.erb +276 -0
- data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -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/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/gem.rb +10 -17
- data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/std.rb +69 -19
- metadata +204 -55
- data/bin/deprec +0 -35
- data/docs/README.slicehost +0 -14
- data/docs/README.svn_trac +0 -19
- data/lib/deprec/capistrano_extensions/actor_extensions.rb +0 -89
- data/lib/deprec/capistrano_extensions/cli_extensions.rb +0 -38
- data/lib/deprec/capistrano_extensions/deprec_extensions.rb +0 -137
- data/lib/deprec/generators/deprec/USAGE +0 -11
- data/lib/deprec/generators/deprec/deprec_generator.rb +0 -24
- data/lib/deprec/generators/deprec/templates/deploy.rb +0 -90
- data/lib/deprec/generators/loader.rb +0 -20
- data/lib/deprec/recipes/apache.rb +0 -91
- data/lib/deprec/recipes/cache_svn.rb +0 -74
- data/lib/deprec/recipes/vmware.rb +0 -114
- data/lib/deprec/templates/trac.ini.erb +0 -106
- data/lib/deprec/third_party/THIRD_PARTY_README +0 -12
- data/lib/deprec/third_party/mongrel_cluster/LICENSE +0 -506
- data/lib/deprec/third_party/mongrel_cluster/recipes.rb +0 -96
- data/lib/deprec/third_party/railsmachine/LICENSE +0 -506
- data/lib/deprec/third_party/railsmachine/recipes/apache.rb +0 -92
- data/lib/deprec/third_party/railsmachine/recipes/mysql.rb +0 -73
- data/lib/deprec/third_party/railsmachine/recipes/templates/httpd-ssl.conf +0 -80
- data/lib/deprec/third_party/railsmachine/recipes/templates/httpd.conf +0 -57
- data/lib/deprec/third_party/vmbuilder/plugins.rb +0 -8
- data/lib/deprec/third_party/vmbuilder/plugins/apt.rb +0 -144
- data/resources/capistrano_include_dotfiles.patch +0 -17
@@ -0,0 +1,197 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deprec do
|
4
|
+
namespace :passenger do
|
5
|
+
|
6
|
+
set(:passenger_install_dir) {
|
7
|
+
if ruby_vm_type == :ree
|
8
|
+
"#{ree_install_dir}/lib/ruby/gems/1.8/gems/passenger-2.0.6"
|
9
|
+
else
|
10
|
+
'/opt/passenger'
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
set(:passenger_document_root) { "#{current_path}/public" }
|
15
|
+
set :passenger_rails_allow_mod_rewrite, 'off'
|
16
|
+
# Default settings for Passenger config files
|
17
|
+
set :passenger_log_level, 0
|
18
|
+
set :passenger_user_switching, 'on'
|
19
|
+
set :passenger_default_user, 'nobody'
|
20
|
+
set :passenger_max_pool_size, 6
|
21
|
+
set :passenger_max_instances_per_app, 0
|
22
|
+
set :passenger_pool_idle_time, 300
|
23
|
+
set :passenger_rails_autodetect, 'on'
|
24
|
+
set :passenger_rails_spawn_method, 'smart' # smart | conservative
|
25
|
+
|
26
|
+
SRC_PACKAGES[:passenger] = {
|
27
|
+
:url => "git://github.com/FooBarWidget/passenger.git",
|
28
|
+
:download_method => :git,
|
29
|
+
:version => 'release-2.0.6', # Specify a tagged release to deploy
|
30
|
+
:configure => '',
|
31
|
+
:make => '',
|
32
|
+
:install => './bin/passenger-install-apache2-module'
|
33
|
+
}
|
34
|
+
|
35
|
+
desc "Install passenger"
|
36
|
+
task :install, :roles => :app do
|
37
|
+
install_deps
|
38
|
+
deprec2.download_src(SRC_PACKAGES[:passenger], src_dir)
|
39
|
+
|
40
|
+
if ruby_vm_type.to_s == 'ree'
|
41
|
+
# Install the Passenger that came with Ruby Enterprise Edition
|
42
|
+
run "yes | #{sudo} env PATH=#{ree_install_dir}/bin:$PATH #{ree_install_dir}/bin/passenger-install-apache2-module"
|
43
|
+
else
|
44
|
+
# Non standard - passenger requires input
|
45
|
+
package_dir = File.join(src_dir, 'passenger.git')
|
46
|
+
dest_dir = passenger_install_dir + '-' + (SRC_PACKAGES[:passenger][:version] || 'trunk')
|
47
|
+
run "#{sudo} rsync -avz #{package_dir}/ #{dest_dir}"
|
48
|
+
run "cd #{dest_dir} && yes '' | #{sudo} ./bin/passenger-install-apache2-module"
|
49
|
+
run "#{sudo} unlink #{passenger_install_dir} 2>/dev/null; #{sudo} ln -sf #{dest_dir} #{passenger_install_dir}"
|
50
|
+
end
|
51
|
+
|
52
|
+
initial_config_push
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
task :initial_config_push, :roles => :web do
|
57
|
+
# XXX Non-standard!
|
58
|
+
# We need to push out the .load and .conf files for Passenger
|
59
|
+
SYSTEM_CONFIG_FILES[:passenger].each do |file|
|
60
|
+
deprec2.render_template(:passenger, file.merge(:remote => true))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Install dependencies for Passenger
|
65
|
+
task :install_deps, :roles => :app do
|
66
|
+
apt.install( {:base => %w(apache2-mpm-prefork apache2-prefork-dev rsync)}, :stable )
|
67
|
+
gem2.install 'fastthread'
|
68
|
+
gem2.install 'rack'
|
69
|
+
gem2.install 'rake'
|
70
|
+
# These are more Rails than Passenger - Mike
|
71
|
+
# gem2.install 'rails'
|
72
|
+
# gem2.install "mysql -- --with-mysql-config='/usr/bin/mysql_config'"
|
73
|
+
# gem2.install 'sqlite3-ruby'
|
74
|
+
# gem2.install 'postgres'
|
75
|
+
end
|
76
|
+
|
77
|
+
SYSTEM_CONFIG_FILES[:passenger] = [
|
78
|
+
|
79
|
+
{:template => 'passenger.load.erb',
|
80
|
+
:path => '/etc/apache2/mods-available/passenger.load',
|
81
|
+
:mode => 0755,
|
82
|
+
:owner => 'root:root'},
|
83
|
+
|
84
|
+
{:template => 'passenger.conf.erb',
|
85
|
+
:path => '/etc/apache2/mods-available/passenger.conf',
|
86
|
+
:mode => 0755,
|
87
|
+
:owner => 'root:root'}
|
88
|
+
|
89
|
+
]
|
90
|
+
|
91
|
+
PROJECT_CONFIG_FILES[:passenger] = [
|
92
|
+
|
93
|
+
{ :template => 'apache_vhost.erb',
|
94
|
+
:path => "apache_vhost",
|
95
|
+
:mode => 0755,
|
96
|
+
:owner => 'root:root'}
|
97
|
+
|
98
|
+
]
|
99
|
+
|
100
|
+
desc "Generate Passenger apache configs (system & project level)."
|
101
|
+
task :config_gen do
|
102
|
+
config_gen_system
|
103
|
+
config_gen_project
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Generate Passenger apache configs (system level) from template."
|
107
|
+
task :config_gen_system do
|
108
|
+
SYSTEM_CONFIG_FILES[:passenger].each do |file|
|
109
|
+
deprec2.render_template(:passenger, file)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Generate Passenger apache configs (project level) from template."
|
114
|
+
task :config_gen_project do
|
115
|
+
PROJECT_CONFIG_FILES[:passenger].each do |file|
|
116
|
+
deprec2.render_template(:passenger, file)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "Push Passenger config files (system & project level) to server"
|
121
|
+
task :config, :roles => :app do
|
122
|
+
config_system
|
123
|
+
config_project
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "Push Passenger configs (system level) to server"
|
127
|
+
task :config_system, :roles => :app do
|
128
|
+
deprec2.push_configs(:passenger, SYSTEM_CONFIG_FILES[:passenger])
|
129
|
+
activate_system
|
130
|
+
end
|
131
|
+
|
132
|
+
desc "Push Passenger configs (project level) to server"
|
133
|
+
task :config_project, :roles => :app do
|
134
|
+
deprec2.push_configs(:passenger, PROJECT_CONFIG_FILES[:passenger])
|
135
|
+
symlink_apache_vhost
|
136
|
+
activate_project
|
137
|
+
end
|
138
|
+
|
139
|
+
task :symlink_apache_vhost, :roles => :app do
|
140
|
+
sudo "ln -sf #{deploy_to}/passenger/apache_vhost #{apache_vhost_dir}/#{application}"
|
141
|
+
end
|
142
|
+
|
143
|
+
task :activate, :roles => :app do
|
144
|
+
activate_system
|
145
|
+
activate_project
|
146
|
+
end
|
147
|
+
|
148
|
+
task :activate_system, :roles => :app do
|
149
|
+
sudo "a2enmod passenger"
|
150
|
+
top.deprec.web.reload
|
151
|
+
end
|
152
|
+
|
153
|
+
task :activate_project, :roles => :app do
|
154
|
+
sudo "a2ensite #{application}"
|
155
|
+
top.deprec.web.reload
|
156
|
+
end
|
157
|
+
|
158
|
+
task :deactivate do
|
159
|
+
puts
|
160
|
+
puts "******************************************************************"
|
161
|
+
puts
|
162
|
+
puts "Danger!"
|
163
|
+
puts
|
164
|
+
puts "Do you want to deactivate just this project or all Passenger"
|
165
|
+
puts "projects on this server? Try a more granular command:"
|
166
|
+
puts
|
167
|
+
puts "cap deprec:passenger:deactivate_system # disable Passenger"
|
168
|
+
puts "cap deprec:passenger:deactivate_project # disable only this project"
|
169
|
+
puts
|
170
|
+
puts "******************************************************************"
|
171
|
+
puts
|
172
|
+
end
|
173
|
+
|
174
|
+
task :deactivate_system, :roles => :app do
|
175
|
+
sudo "a2dismod passenger"
|
176
|
+
top.deprec.web.reload
|
177
|
+
end
|
178
|
+
|
179
|
+
task :deactivate_project, :roles => :app do
|
180
|
+
sudo "a2dissite #{application}"
|
181
|
+
top.deprec.web.reload
|
182
|
+
end
|
183
|
+
|
184
|
+
desc "Restart Application"
|
185
|
+
task :restart, :roles => :app do
|
186
|
+
run "touch #{current_path}/tmp/restart.txt"
|
187
|
+
end
|
188
|
+
|
189
|
+
desc "Restart Apache"
|
190
|
+
task :restart_apache, :roles => :passenger do
|
191
|
+
run "#{sudo} /etc/init.d/apache2 restart"
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
# ref: http://www.howtoforge.com/local_debian_ubuntu_mirror
|
4
|
+
namespace :deprec do
|
5
|
+
|
6
|
+
set :apt_mirror_hostname, 'archive.ubuntu.com'
|
7
|
+
set :apt_releases_to_mirror, %w(gutsy)
|
8
|
+
|
9
|
+
namespace :apt_normal do # XXX Find a better name
|
10
|
+
# :apt was clashing with the vmbuilder plugin
|
11
|
+
|
12
|
+
SYSTEM_CONFIG_FILES[:apt] = [
|
13
|
+
|
14
|
+
{:template => 'sources.list',
|
15
|
+
:path => '/etc/apt/sources.list',
|
16
|
+
:mode => 0755,
|
17
|
+
:owner => 'root:root'}
|
18
|
+
]
|
19
|
+
|
20
|
+
desc <<-DESC
|
21
|
+
Generate apt config from template. Note that this does not
|
22
|
+
push the config to the server, it merely generates required
|
23
|
+
configuration files. These should be kept under source control.
|
24
|
+
The can be pushed to the server with the :config task.
|
25
|
+
DESC
|
26
|
+
task :config_gen do
|
27
|
+
SYSTEM_CONFIG_FILES[:apt].each do |file|
|
28
|
+
deprec2.render_template(:apt, file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Push apt_mirror config files to server"
|
33
|
+
task :config do
|
34
|
+
deprec2.push_configs(:apt, SYSTEM_CONFIG_FILES[:apt])
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
namespace :apt_mirror do
|
40
|
+
|
41
|
+
desc "Install apt-mirror"
|
42
|
+
task :install, :roles => :apt_mirror do
|
43
|
+
install_deps
|
44
|
+
SYSTEM_CONFIG_FILES[:apt_mirror].each do |file|
|
45
|
+
deprec2.render_template(:apt_mirror, file.merge(:remote => true))
|
46
|
+
end
|
47
|
+
activate
|
48
|
+
end
|
49
|
+
|
50
|
+
# install dependencies for apt_mirror
|
51
|
+
task :install_deps do
|
52
|
+
apt.install( {:base => %w(apt-mirror apache2 cron)}, :stable )
|
53
|
+
end
|
54
|
+
|
55
|
+
SYSTEM_CONFIG_FILES[:apt_mirror] = [
|
56
|
+
|
57
|
+
{:template => 'mirror.list',
|
58
|
+
:path => '/etc/apt/mirror.list',
|
59
|
+
:mode => 0755,
|
60
|
+
:owner => 'root:root'},
|
61
|
+
|
62
|
+
{:template => 'apt-mirror-cron',
|
63
|
+
:path => '/etc/cron.d/apt-mirror',
|
64
|
+
:mode => 0755,
|
65
|
+
:owner => 'root:root'}
|
66
|
+
]
|
67
|
+
|
68
|
+
desc <<-DESC
|
69
|
+
Generate apt_mirror config from template. Note that this does not
|
70
|
+
push the config to the server, it merely generates required
|
71
|
+
configuration files. These should be kept under source control.
|
72
|
+
The can be pushed to the server with the :config task.
|
73
|
+
DESC
|
74
|
+
task :config_gen do
|
75
|
+
SYSTEM_CONFIG_FILES[:apt_mirror].each do |file|
|
76
|
+
deprec2.render_template(:apt_mirror, file)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Push apt_mirror config files to server"
|
81
|
+
task :config, :roles => :apt_mirror do
|
82
|
+
deprec2.push_configs(:apt_mirror, SYSTEM_CONFIG_FILES[:apt_mirror])
|
83
|
+
end
|
84
|
+
|
85
|
+
# Create mirror for the first time
|
86
|
+
#
|
87
|
+
# su - apt-mirror -c apt-mirror
|
88
|
+
|
89
|
+
# Add cron job to update
|
90
|
+
|
91
|
+
# Symlink for apache
|
92
|
+
# ln -s /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu /var/www/ubuntu
|
93
|
+
|
94
|
+
# Update sources.list on all hosts:
|
95
|
+
# deb http://192.168.0.100/ubuntu/ gutsy main restricted universe
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deprec do
|
4
|
+
namespace :ar_sendmail do
|
5
|
+
|
6
|
+
desc "Install ar_mailer"
|
7
|
+
task :install, :roles => :app do
|
8
|
+
gem2.install 'ar_mailer'
|
9
|
+
end
|
10
|
+
|
11
|
+
# install dependencies for ar_sendmail
|
12
|
+
task :install_deps, :roles => :app do
|
13
|
+
#pass
|
14
|
+
end
|
15
|
+
|
16
|
+
PROJECT_CONFIG_FILES[:ar_sendmail] = [
|
17
|
+
|
18
|
+
{:template => 'monit.conf.erb',
|
19
|
+
:path => "monit.conf",
|
20
|
+
:mode => 0600,
|
21
|
+
:owner => 'root:root'},
|
22
|
+
|
23
|
+
{:template => 'logrotate.conf.erb',
|
24
|
+
:path => "logrotate.conf",
|
25
|
+
:mode => 0644,
|
26
|
+
:owner => 'root:root'}
|
27
|
+
]
|
28
|
+
|
29
|
+
task :config_gen do
|
30
|
+
config_gen_project
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Generate configuration file(s) for ar_sendmail from template(s)"
|
34
|
+
task :config_gen_project do
|
35
|
+
PROJECT_CONFIG_FILES[:ar_sendmail].each do |file|
|
36
|
+
deprec2.render_template(:ar_sendmail, file)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Push ar_sendmail config files to server"
|
41
|
+
task :config, :roles => :app do
|
42
|
+
config_project
|
43
|
+
end
|
44
|
+
|
45
|
+
task :config_project, :roles => :app do
|
46
|
+
deprec2.push_configs(:ar_sendmail, PROJECT_CONFIG_FILES[:ar_sendmail])
|
47
|
+
symlink_monit_config
|
48
|
+
symlink_logrotate_config
|
49
|
+
end
|
50
|
+
|
51
|
+
task :symlink_monit_config, :roles => :app do
|
52
|
+
deprec2.mkdir(monit_confd_dir, :via => :sudo)
|
53
|
+
sudo "ln -sf #{deploy_to}/ar_sendmail/monit.conf #{monit_confd_dir}/ar_sendmail_#{application}.conf"
|
54
|
+
end
|
55
|
+
|
56
|
+
task :unlink_monit_config, :roles => :app do
|
57
|
+
link = "#{monit_confd_dir}/ar_sendmail_#{application}.conf"
|
58
|
+
sudo "test -L #{link} && unlink #{link}"
|
59
|
+
end
|
60
|
+
|
61
|
+
task :symlink_logrotate_config, :roles => :app do
|
62
|
+
sudo "ln -sf #{deploy_to}/ar_sendmail/logrotate.conf /etc/logrotate.d/ar_sendmail-#{application}"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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(ruby).each do |package|
|
13
|
+
namespace "deprec:#{package}" do
|
14
|
+
|
15
|
+
desc "Install #{package.capitalize}"
|
16
|
+
task :install do
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(web app db).each do |server|
|
23
|
+
namespace "deprec:#{server}" do
|
24
|
+
|
25
|
+
desc "Install #{server.capitalize} server"
|
26
|
+
task :install, :roles => server do
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Generate config file(s) for #{server} server from template(s)"
|
30
|
+
task :config_gen do
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Deploy configuration files(s) for #{server} server"
|
34
|
+
task :config, :roles => server do
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Start #{server} server"
|
38
|
+
task :start, :roles => server do
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Stop #{server} server"
|
42
|
+
task :stop, :roles => server do
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Stop #{server} server"
|
46
|
+
task :restart, :roles => server do
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Enable startup script for #{server} server"
|
50
|
+
task :activate, :roles => server do
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Disable startup script for #{server} server"
|
54
|
+
task :deactivate, :roles => server do
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Backup data for #{server} server"
|
58
|
+
task :backup, :roles => server do
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Restore data for #{server} server from backup"
|
62
|
+
task :restore, :roles => server do
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deprec do
|
4
|
+
namespace :mysql do
|
5
|
+
|
6
|
+
set :mysql_admin_user, 'root'
|
7
|
+
set(:mysql_admin_pass) { Capistrano::CLI.password_prompt "Enter database password for '#{mysql_admin_user}':"}
|
8
|
+
|
9
|
+
# Installation
|
10
|
+
|
11
|
+
desc "Install mysql"
|
12
|
+
task :install, :roles => :db do
|
13
|
+
install_deps
|
14
|
+
start
|
15
|
+
# symlink_mysql_sockfile # XXX still needed?
|
16
|
+
end
|
17
|
+
|
18
|
+
# Install dependencies for Mysql
|
19
|
+
task :install_deps, :roles => :db do
|
20
|
+
apt.install( {:base => %w(mysql-server mysql-client libmysqlclient15-dev)}, :stable )
|
21
|
+
end
|
22
|
+
|
23
|
+
# task :symlink_mysql_sockfile, :roles => :db do
|
24
|
+
# # rails puts "socket: /tmp/mysql.sock" into config/database.yml
|
25
|
+
# # this is not the location for our ubuntu's mysql socket file
|
26
|
+
# # so we create this link to make deployment using rails defaults simpler
|
27
|
+
# sudo "ln -sf /var/run/mysqld/mysqld.sock /tmp/mysql.sock"
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Configuration
|
31
|
+
|
32
|
+
SYSTEM_CONFIG_FILES[:mysql] = [
|
33
|
+
|
34
|
+
{:template => "my.cnf.erb",
|
35
|
+
:path => '/etc/mysql/my.cnf',
|
36
|
+
:mode => 0644,
|
37
|
+
:owner => 'root:root'}
|
38
|
+
]
|
39
|
+
|
40
|
+
desc "Generate configuration file(s) for mysql from template(s)"
|
41
|
+
task :config_gen do
|
42
|
+
SYSTEM_CONFIG_FILES[:mysql].each do |file|
|
43
|
+
deprec2.render_template(:mysql, file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Push mysql config files to server"
|
48
|
+
task :config, :roles => :db do
|
49
|
+
deprec2.push_configs(:mysql, SYSTEM_CONFIG_FILES[:mysql])
|
50
|
+
end
|
51
|
+
|
52
|
+
task :activate, :roles => :db do
|
53
|
+
send(run_method, "update-rc.d mysql defaults")
|
54
|
+
end
|
55
|
+
|
56
|
+
task :deactivate, :roles => :db do
|
57
|
+
send(run_method, "update-rc.d -f mysql remove")
|
58
|
+
end
|
59
|
+
|
60
|
+
# Control
|
61
|
+
|
62
|
+
desc "Start Mysql"
|
63
|
+
task :start, :roles => :db do
|
64
|
+
send(run_method, "/etc/init.d/mysql start")
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Stop Mysql"
|
68
|
+
task :stop, :roles => :db do
|
69
|
+
send(run_method, "/etc/init.d/mysql stop")
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Restart Mysql"
|
73
|
+
task :restart, :roles => :db do
|
74
|
+
send(run_method, "/etc/init.d/mysql restart")
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Reload Mysql"
|
78
|
+
task :reload, :roles => :db do
|
79
|
+
send(run_method, "/etc/init.d/mysql reload")
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
task :backup, :roles => :db do
|
84
|
+
end
|
85
|
+
|
86
|
+
task :restore, :roles => :db do
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Create a mysql user"
|
90
|
+
task :create_user, :roles => :db do
|
91
|
+
# TBA
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Create a database"
|
95
|
+
task :create_database, :roles => :db do
|
96
|
+
cmd = "CREATE DATABASE IF NOT EXISTS #{db_name}"
|
97
|
+
run "mysql -u #{mysql_admin_user} -p -e '#{cmd}'" do |channel, stream, data|
|
98
|
+
if data =~ /^Enter password:/
|
99
|
+
channel.send_data "#{mysql_admin_pass}\n"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "Grant user access to database"
|
105
|
+
task :grant_user_access_to_database, :roles => :db do
|
106
|
+
cmd = "GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@localhost IDENTIFIED BY '#{db_password}';"
|
107
|
+
run "mysql -u #{mysql_admin_user} -p #{db_name} -e \"#{cmd}\"" do |channel, stream, data|
|
108
|
+
if data =~ /^Enter password:/
|
109
|
+
channel.send_data "#{mysql_admin_pass}\n"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# Setup replication
|
120
|
+
#
|
121
|
+
|
122
|
+
# setup user for repl
|
123
|
+
# GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.yourdomain.com' IDENTIFIED BY 'slavepass';
|
124
|
+
|
125
|
+
# get current position of binlog
|
126
|
+
# mysql> FLUSH TABLES WITH READ LOCK;
|
127
|
+
# Query OK, 0 rows affected (0.00 sec)
|
128
|
+
#
|
129
|
+
# mysql> SHOW MASTER STATUS;
|
130
|
+
# +------------------+----------+--------------+------------------+
|
131
|
+
# | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
|
132
|
+
# +------------------+----------+--------------+------------------+
|
133
|
+
# | mysql-bin.000012 | 296 | | |
|
134
|
+
# +------------------+----------+--------------+------------------+
|
135
|
+
# 1 row in set (0.00 sec)
|
136
|
+
#
|
137
|
+
# # get current data
|
138
|
+
# mysqldump --all-databases --master-data >dbdump.db
|
139
|
+
#
|
140
|
+
# UNLOCK TABLES;
|
141
|
+
|
142
|
+
|
143
|
+
# Replication Features and Issues
|
144
|
+
# http://dev.mysql.com/doc/refman/5.0/en/replication-features.html
|