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,53 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deprec do
|
4
|
+
namespace :memcache do
|
5
|
+
|
6
|
+
set :memcache_ip, '127.0.0.1'
|
7
|
+
set :memcache_port, 11211
|
8
|
+
set :memcache_memory, 256
|
9
|
+
|
10
|
+
# XXX needs thought/work
|
11
|
+
task :memcached_start do
|
12
|
+
run "memcached -d -m #{memcache_memory} -l #{memcache_ip} -p #{memcache_port}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# XXX needs thought/work
|
16
|
+
task :memcached_stop do
|
17
|
+
run "killall memcached"
|
18
|
+
end
|
19
|
+
|
20
|
+
# XXX needs thought/work
|
21
|
+
task :memcached_restart do
|
22
|
+
memcached_stop
|
23
|
+
memcached_start
|
24
|
+
end
|
25
|
+
|
26
|
+
task :install_memcached do
|
27
|
+
# rpmforge contains same version of memcached, so let's use packages here
|
28
|
+
=begin
|
29
|
+
version = 'memcached-1.2.2'
|
30
|
+
set :src_package, {
|
31
|
+
:file => version + '.tar.gz',
|
32
|
+
:md5sum => 'a08851f7fa7b15e92ee6320b7a79c321 memcached-1.2.2.tar.gz',
|
33
|
+
:dir => version,
|
34
|
+
:url => "http://www.danga.com/memcached/dist/#{version}.tar.gz",
|
35
|
+
:unpack => "tar zxf #{version}.tar.gz;",
|
36
|
+
:configure => %w{
|
37
|
+
./configure
|
38
|
+
--prefix=/usr/local
|
39
|
+
--with-libevent=/usr/lib/
|
40
|
+
;
|
41
|
+
}.reject{|arg| arg.match '#'}.join(' '),
|
42
|
+
:make => 'make;',
|
43
|
+
:install => 'make install;',
|
44
|
+
:post_install => 'install -b scripts/memcached-init /etc/init.d/memcached;'
|
45
|
+
}
|
46
|
+
=end
|
47
|
+
apt.install( {:base => %w(memcached libevent libevent-devel)}, :stable )
|
48
|
+
#deprec.download_src(src_package, src_dir)
|
49
|
+
#deprec.install_from_src(src_package, src_dir)
|
50
|
+
end
|
51
|
+
end end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright 2008 by Saulius Grigaitis. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
|
4
|
+
namespace :centos do
|
5
|
+
namespace :merb do
|
6
|
+
|
7
|
+
set :merb_servers, 2
|
8
|
+
set :merb_port, 8000
|
9
|
+
set(:merb_user) { mongrel_user + application }
|
10
|
+
set :merb_group_prefix, 'app_'
|
11
|
+
set(:merb_group) { merb_group_prefix + application }
|
12
|
+
|
13
|
+
|
14
|
+
# Install
|
15
|
+
|
16
|
+
desc "Install merb"
|
17
|
+
task :install, :roles => :app do
|
18
|
+
install_deps
|
19
|
+
%w(core plugins more).each do |gem|
|
20
|
+
package_info = {
|
21
|
+
:filename => "merb-#{gem}",
|
22
|
+
:dir => "merb-#{gem}",
|
23
|
+
:unpack => "git clone git://github.com/wycats/merb-#{gem}.git;"
|
24
|
+
}
|
25
|
+
deprec2.unpack_src(package_info, src_dir)
|
26
|
+
sudo "sh -c 'cd #{src_dir}/merb-#{gem}; rake install'"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
task :install_deps do
|
31
|
+
top.centos.mongrel.install
|
32
|
+
top.centos.git.install
|
33
|
+
gem2.install(%w(rack mongrel json json_pure erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory ruby2ruby))
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# Control
|
38
|
+
=begin
|
39
|
+
desc "Start application server."
|
40
|
+
task :start, :roles => :app do
|
41
|
+
send(run_method, "/usr/local/bin/merb --user #{merb_user} --group #{merb_group} --daemonize --cluster-nodes #{merb_servers} --merb-root #{current_path} --port #{merb_port} -e production")
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Stop application server."
|
45
|
+
task :stop, :roles => :app do
|
46
|
+
send(run_method, "sh -c 'cd #{current_path} && merb -k all --merb-root'")
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Restart application server."
|
50
|
+
task :restart, :roles => :app do
|
51
|
+
top.centos.merb.stop
|
52
|
+
top.centos.merb.start
|
53
|
+
end
|
54
|
+
=end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
|
4
|
+
namespace :centos do
|
5
|
+
namespace :mongrel do
|
6
|
+
|
7
|
+
set :mongrel_servers, 2
|
8
|
+
set :mongrel_port, 8000
|
9
|
+
set :mongrel_address, "127.0.0.1"
|
10
|
+
set(:mongrel_environment) { rails_env }
|
11
|
+
set(:mongrel_log_dir) { "#{deploy_to}/shared/log" }
|
12
|
+
set(:mongrel_pid_dir) { "#{deploy_to}/shared/pids" }
|
13
|
+
set :mongrel_conf_dir, '/etc/mongrel_cluster'
|
14
|
+
set(:mongrel_conf) { "/etc/mongrel_cluster/#{application}.yml" }
|
15
|
+
set :mongrel_user_prefix, 'mongrel_'
|
16
|
+
set(:mongrel_user) { mongrel_user_prefix + application }
|
17
|
+
set :mongrel_group_prefix, 'app_'
|
18
|
+
set(:mongrel_group) { mongrel_group_prefix + application }
|
19
|
+
|
20
|
+
|
21
|
+
# Install
|
22
|
+
|
23
|
+
desc "Install mongrel"
|
24
|
+
task :install do
|
25
|
+
gem2.install 'mongrel'
|
26
|
+
gem2.install 'mongrel_cluster'
|
27
|
+
gem2.install 'swiftiply'
|
28
|
+
symlink_mongrel_rails
|
29
|
+
SYSTEM_CONFIG_FILES[:mongrel].each do |file|
|
30
|
+
deprec2.render_template(:mongrel, file.merge(:remote=>true))
|
31
|
+
end
|
32
|
+
activate_system
|
33
|
+
end
|
34
|
+
|
35
|
+
task :symlink_mongrel_rails do
|
36
|
+
sudo "ln -sf /usr/local/bin/mongrel_rails /usr/bin/mongrel_rails"
|
37
|
+
end
|
38
|
+
|
39
|
+
task :symlink_logrotate_config do
|
40
|
+
sudo "ln -sf #{deploy_to}/mongrel/logrotate.conf /etc/logrotate.d/mongrel-#{application}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Configure
|
44
|
+
|
45
|
+
SYSTEM_CONFIG_FILES[:mongrel] = [
|
46
|
+
|
47
|
+
{:template => 'mongrel_cluster-init-script',
|
48
|
+
:path => '/etc/init.d/mongrel_cluster',
|
49
|
+
:mode => 0755,
|
50
|
+
:owner => 'root:root'}
|
51
|
+
|
52
|
+
]
|
53
|
+
|
54
|
+
PROJECT_CONFIG_FILES[:mongrel] = [
|
55
|
+
|
56
|
+
{:template => 'mongrel_cluster.yml.erb',
|
57
|
+
:path => 'cluster.yml',
|
58
|
+
:mode => 0644,
|
59
|
+
:owner => 'root:root'},
|
60
|
+
|
61
|
+
{:template => 'monit.conf.erb',
|
62
|
+
:path => "monit.conf",
|
63
|
+
:mode => 0600,
|
64
|
+
:owner => 'root:root'},
|
65
|
+
|
66
|
+
{:template => 'logrotate.conf.erb',
|
67
|
+
:path => "logrotate.conf",
|
68
|
+
:mode => 0644,
|
69
|
+
:owner => 'root:root'}
|
70
|
+
|
71
|
+
]
|
72
|
+
|
73
|
+
desc "Generate configuration file(s) for mongrel from template(s)"
|
74
|
+
task :config_gen do
|
75
|
+
config_gen_system
|
76
|
+
config_gen_project
|
77
|
+
end
|
78
|
+
|
79
|
+
task :config_gen_system do
|
80
|
+
SYSTEM_CONFIG_FILES[:mongrel].each do |file|
|
81
|
+
deprec2.render_template(:mongrel, file)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
task :config_gen_project do
|
86
|
+
PROJECT_CONFIG_FILES[:mongrel].each do |file|
|
87
|
+
deprec2.render_template(:mongrel, file)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'Deploy configuration files(s) for mongrel'
|
92
|
+
task :config, :roles => :app do
|
93
|
+
config_system
|
94
|
+
config_project
|
95
|
+
end
|
96
|
+
|
97
|
+
task :config_system, :roles => :app do
|
98
|
+
deprec2.push_configs(:mongrel, SYSTEM_CONFIG_FILES[:mongrel])
|
99
|
+
end
|
100
|
+
|
101
|
+
task :config_project, :roles => :app do
|
102
|
+
create_mongrel_user_and_group
|
103
|
+
deprec2.push_configs(:mongrel, PROJECT_CONFIG_FILES[:mongrel])
|
104
|
+
symlink_mongrel_cluster
|
105
|
+
symlink_monit_config
|
106
|
+
symlink_logrotate_config
|
107
|
+
end
|
108
|
+
|
109
|
+
task :symlink_monit_config, :roles => :app do
|
110
|
+
deprec2.mkdir(monit_confd_dir, :via => :sudo)
|
111
|
+
sudo "ln -sf #{deploy_to}/mongrel/monit.conf #{monit_confd_dir}/mongrel_#{application}.conf"
|
112
|
+
end
|
113
|
+
|
114
|
+
task :unlink_monit_config, :roles => :app do
|
115
|
+
sudo "test -L #{monit_confd_dir}/mongrel_#{application}.conf && unlink #{monit_confd_dir}/mongrel_#{application}.conf"
|
116
|
+
end
|
117
|
+
|
118
|
+
task :symlink_mongrel_cluster, :roles => :app do
|
119
|
+
deprec2.mkdir(mongrel_conf_dir, :via => :sudo)
|
120
|
+
sudo "ln -sf #{deploy_to}/mongrel/cluster.yml #{mongrel_conf}"
|
121
|
+
end
|
122
|
+
|
123
|
+
task :unlink_mongrel_cluster, :roles => :app do
|
124
|
+
sudo "test -L #{mongrel_conf} && unlink #{mongrel_conf}"
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
# Control
|
129
|
+
|
130
|
+
desc "Start application server."
|
131
|
+
task :start, :roles => :app do
|
132
|
+
send(run_method, "mongrel_rails cluster::start --clean -C #{mongrel_conf}")
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "Stop application server."
|
136
|
+
task :stop, :roles => :app do
|
137
|
+
send(run_method, "mongrel_rails cluster::stop -C #{mongrel_conf}")
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Restart application server."
|
141
|
+
task :restart, :roles => :app do
|
142
|
+
send(run_method, "mongrel_rails cluster::restart --clean -C #{mongrel_conf}")
|
143
|
+
end
|
144
|
+
|
145
|
+
task :activate, :roles => :app do
|
146
|
+
activate_system
|
147
|
+
activate_project
|
148
|
+
end
|
149
|
+
|
150
|
+
task :activate_system, :roles => :app do
|
151
|
+
send(run_method, "/sbin/chkconfig --add mongrel_cluster")
|
152
|
+
send(run_method, "/sbin/chkconfig --level 45 mongrel_cluster on")
|
153
|
+
end
|
154
|
+
|
155
|
+
task :activate_project, :roles => :app do
|
156
|
+
symlink_mongrel_cluster
|
157
|
+
symlink_monit_config
|
158
|
+
end
|
159
|
+
|
160
|
+
task :deactivate, :roles => :app do
|
161
|
+
puts
|
162
|
+
puts "******************************************************************"
|
163
|
+
puts
|
164
|
+
puts "Danger!"
|
165
|
+
puts
|
166
|
+
puts "Do you want to deactivate just this project or all mongrel"
|
167
|
+
puts "clusters on this server? Try a more granular command:"
|
168
|
+
puts
|
169
|
+
puts "cap deprec:mongrel:deactivate_system # disable all clusters"
|
170
|
+
puts "cap deprec:mongrel:deactivate_project # disable only this project"
|
171
|
+
puts
|
172
|
+
puts "******************************************************************"
|
173
|
+
puts
|
174
|
+
end
|
175
|
+
|
176
|
+
task :deactivate_system, :roles => :app do
|
177
|
+
send(run_method, "/sbin/chkconfig --del mongrel_cluster")
|
178
|
+
end
|
179
|
+
|
180
|
+
task :deactivate_project, :roles => :app do
|
181
|
+
unlink_mongrel_cluster
|
182
|
+
unlink_monit_config
|
183
|
+
restart
|
184
|
+
end
|
185
|
+
|
186
|
+
task :backup, :roles => :app do
|
187
|
+
end
|
188
|
+
|
189
|
+
task :restore, :roles => :app do
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "create user and group for mongel to run as"
|
193
|
+
task :create_mongrel_user_and_group, :roles => :app do
|
194
|
+
deprec2.groupadd(mongrel_group)
|
195
|
+
deprec2.useradd(mongrel_user, :group => mongrel_group, :homedir => false)
|
196
|
+
# Set the primary group for the mongrel user (in case user already existed
|
197
|
+
# when previous command was run)
|
198
|
+
sudo "/usr/sbin/usermod -g #{mongrel_group} #{mongrel_user}"
|
199
|
+
end
|
200
|
+
|
201
|
+
desc "set group ownership and permissions on dirs mongrel needs to write to"
|
202
|
+
task :set_perms_for_mongrel_dirs, :roles => :app do
|
203
|
+
tmp_dir = "#{deploy_to}/current/tmp"
|
204
|
+
shared_dir = "#{deploy_to}/shared"
|
205
|
+
files = ["#{mongrel_log_dir}/mongrel.log", "#{mongrel_log_dir}/#{rails_env}.log"]
|
206
|
+
|
207
|
+
sudo "chgrp -R #{mongrel_group} #{tmp_dir} #{shared_dir}"
|
208
|
+
sudo "chmod -R g+w #{tmp_dir} #{shared_dir}"
|
209
|
+
# set owner and group of log files
|
210
|
+
files.each { |file|
|
211
|
+
sudo "touch #{file}"
|
212
|
+
sudo "chown #{mongrel_user} #{file}"
|
213
|
+
sudo "chgrp #{mongrel_group} #{file}"
|
214
|
+
sudo "chmod g+w #{file}"
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :centos do namespace :monit do
|
4
|
+
|
5
|
+
set :monit_user, 'monit'
|
6
|
+
set :monit_group, 'monit'
|
7
|
+
set :monit_confd_dir, '/etc/monit.d'
|
8
|
+
|
9
|
+
set :monit_check_interval, 60
|
10
|
+
set :monit_log, 'syslog facility log_daemon'
|
11
|
+
set :monit_mailserver, nil
|
12
|
+
set :monit_mail_from, 'monit@deprec.enabled.slice'
|
13
|
+
set :monit_alert_recipients, %w(root@localhost)
|
14
|
+
set :monit_timeout_recipients, %w(root@localhost)
|
15
|
+
set :monit_webserver_enabled, true
|
16
|
+
set :monit_webserver_port, 2812
|
17
|
+
set :monit_webserver_address, 'localhost'
|
18
|
+
set :monit_webserver_allowed_hosts_and_networks, %w(localhost)
|
19
|
+
set :monit_webserver_auth_user, 'admin'
|
20
|
+
set :monit_webserver_auth_pass, 'monit'
|
21
|
+
|
22
|
+
# Upstream changes: http://www.tildeslash.com/monit/dist/CHANGES.txt
|
23
|
+
|
24
|
+
SRC_PACKAGES[:monit] = {
|
25
|
+
:filename => 'monit-4.10.1.tar.gz',
|
26
|
+
:md5sum => "d3143b0bbd79b53f1b019d2fc1dae656 monit-4.10.1.tar.gz",
|
27
|
+
:dir => 'monit-4.10.1',
|
28
|
+
:url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz",
|
29
|
+
:unpack => "tar zxf monit-4.10.1.tar.gz;",
|
30
|
+
:configure => %w(
|
31
|
+
./configure
|
32
|
+
;
|
33
|
+
).reject{|arg| arg.match '#'}.join(' '),
|
34
|
+
:make => 'make;',
|
35
|
+
:install => 'make install;',
|
36
|
+
:version => 'c4.10.1',
|
37
|
+
:release => '1'
|
38
|
+
}
|
39
|
+
|
40
|
+
desc "Install monit"
|
41
|
+
task :install do
|
42
|
+
install_deps
|
43
|
+
deprec2.download_src(SRC_PACKAGES[:monit], src_dir)
|
44
|
+
yum.install_from_src(SRC_PACKAGES[:monit], src_dir)
|
45
|
+
SYSTEM_CONFIG_FILES[:monit].each do |file|
|
46
|
+
deprec2.render_template(:monit, file.merge(:remote=>true))
|
47
|
+
end
|
48
|
+
activate
|
49
|
+
end
|
50
|
+
|
51
|
+
# install dependencies for monit
|
52
|
+
task :install_deps do
|
53
|
+
apt.install( {:base => %w(flex bison openssl openssl-devel)}, :stable )
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
SYSTEM_CONFIG_FILES[:monit] = [
|
58
|
+
|
59
|
+
{:template => 'monit-init-script',
|
60
|
+
:path => '/etc/init.d/monit',
|
61
|
+
:mode => 0755,
|
62
|
+
:owner => 'root:root'},
|
63
|
+
|
64
|
+
{:template => 'monitrc.erb',
|
65
|
+
:path => "/etc/monitrc",
|
66
|
+
:mode => 0700,
|
67
|
+
:owner => 'root:root'},
|
68
|
+
|
69
|
+
{:template => 'nothing',
|
70
|
+
:path => "/etc/monit.d/nothing",
|
71
|
+
:mode => 0700,
|
72
|
+
:owner => 'root:root'}
|
73
|
+
]
|
74
|
+
|
75
|
+
desc <<-DESC
|
76
|
+
Generate nginx config from template. Note that this does not
|
77
|
+
push the config to the server, it merely generates required
|
78
|
+
configuration files. These should be kept under source control.
|
79
|
+
The can be pushed to the server with the :config task.
|
80
|
+
DESC
|
81
|
+
task :config_gen do
|
82
|
+
SYSTEM_CONFIG_FILES[:monit].each do |file|
|
83
|
+
deprec2.render_template(:monit, file)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Push monit config files to server"
|
88
|
+
task :config do
|
89
|
+
deprec2.push_configs(:monit, SYSTEM_CONFIG_FILES[:monit])
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Start Monit"
|
93
|
+
task :start, :roles => :app do
|
94
|
+
send(run_method, "/etc/init.d/monit start")
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Stop Monit"
|
98
|
+
task :stop, :roles => :app do
|
99
|
+
send(run_method, "/etc/init.d/monit stop")
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "Restart Monit"
|
103
|
+
task :restart, :roles => :app do
|
104
|
+
send(run_method, "/etc/init.d/monit restart")
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Reload Monit"
|
108
|
+
task :reload, :roles => :app do
|
109
|
+
send(run_method, "/etc/init.d/monit reload")
|
110
|
+
end
|
111
|
+
|
112
|
+
desc <<-DESC
|
113
|
+
Activate monit start scripts on server.
|
114
|
+
Setup server to start monit on boot.
|
115
|
+
DESC
|
116
|
+
task :activate do
|
117
|
+
# TODO: service monit does not support chkconfig
|
118
|
+
# send(run_method, "/sbin/chkconfig --add monit")
|
119
|
+
# send(run_method, "/sbin/chkconfig --level 45 monit on")
|
120
|
+
end
|
121
|
+
|
122
|
+
desc <<-DESC
|
123
|
+
Dectivate monit start scripts on server.
|
124
|
+
Setup server to start monit on boot.
|
125
|
+
DESC
|
126
|
+
task :deactivate do
|
127
|
+
send(run_method, "/sbin/chkconfig --del monit")
|
128
|
+
end
|
129
|
+
|
130
|
+
task :backup do
|
131
|
+
# there's nothing to backup for monit
|
132
|
+
end
|
133
|
+
|
134
|
+
task :restore do
|
135
|
+
# there's nothing to restore for monit
|
136
|
+
end
|
137
|
+
|
138
|
+
end end
|
139
|
+
end
|