le1t0-deprec 2.1.6.001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/CHANGELOG +444 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +154 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +139 -0
  7. data/docs/EXAMPLE-installing_tracks.txt +41 -0
  8. data/docs/README.nagios +22 -0
  9. data/docs/README.rails +17 -0
  10. data/docs/config_gen_explained.txt +39 -0
  11. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  12. data/docs/deprec-1.x/notes.txt +12 -0
  13. data/docs/old/deprec_banner.gif +0 -0
  14. data/docs/windows_linux.txt +350 -0
  15. data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
  16. data/docs/xen/xen-tools-notes.txt +31 -0
  17. data/docs/xen/xen_on_hardy.txt +39 -0
  18. data/lib/deprec.rb +42 -0
  19. data/lib/deprec/capistrano_extensions.rb +446 -0
  20. data/lib/deprec/recipes.rb +7 -0
  21. data/lib/deprec/recipes/aoe.rb +79 -0
  22. data/lib/deprec/recipes/app/mongrel.rb +213 -0
  23. data/lib/deprec/recipes/app/passenger.rb +190 -0
  24. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  25. data/lib/deprec/recipes/aspell.rb +22 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/cap.rb +39 -0
  28. data/lib/deprec/recipes/chef.rb +68 -0
  29. data/lib/deprec/recipes/collectd.rb +112 -0
  30. data/lib/deprec/recipes/db/couchdb.rb +107 -0
  31. data/lib/deprec/recipes/db/mysql.rb +194 -0
  32. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  33. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  34. data/lib/deprec/recipes/ddclient.rb +51 -0
  35. data/lib/deprec/recipes/deprec.rb +167 -0
  36. data/lib/deprec/recipes/deprecated.rb +71 -0
  37. data/lib/deprec/recipes/drbd.rb +137 -0
  38. data/lib/deprec/recipes/dummy.rb +22 -0
  39. data/lib/deprec/recipes/example.rb +115 -0
  40. data/lib/deprec/recipes/git.rb +97 -0
  41. data/lib/deprec/recipes/gitosis.rb.disabled +55 -0
  42. data/lib/deprec/recipes/glusterfs.rb +176 -0
  43. data/lib/deprec/recipes/god.rb +70 -0
  44. data/lib/deprec/recipes/haproxy.rb +115 -0
  45. data/lib/deprec/recipes/heartbeat.rb +138 -0
  46. data/lib/deprec/recipes/imagemagick/imagemagick_bin.rb +24 -0
  47. data/lib/deprec/recipes/imagemagick/imagemagick_src.rb +39 -0
  48. data/lib/deprec/recipes/integrity.rb +108 -0
  49. data/lib/deprec/recipes/iptables.rb +94 -0
  50. data/lib/deprec/recipes/java.rb +23 -0
  51. data/lib/deprec/recipes/keepalived.rb +78 -0
  52. data/lib/deprec/recipes/ldap.rb +52 -0
  53. data/lib/deprec/recipes/logrotate.rb +56 -0
  54. data/lib/deprec/recipes/lvm.rb +20 -0
  55. data/lib/deprec/recipes/memcache.rb +49 -0
  56. data/lib/deprec/recipes/mongodb.rb +94 -0
  57. data/lib/deprec/recipes/monit.rb +135 -0
  58. data/lib/deprec/recipes/mysql_proxy.rb +67 -0
  59. data/lib/deprec/recipes/nagios.rb +361 -0
  60. data/lib/deprec/recipes/network.rb +116 -0
  61. data/lib/deprec/recipes/ntp.rb +103 -0
  62. data/lib/deprec/recipes/php.rb +58 -0
  63. data/lib/deprec/recipes/postfix.rb +115 -0
  64. data/lib/deprec/recipes/profiles.rb +125 -0
  65. data/lib/deprec/recipes/raid/amcc_3ware.rb +21 -0
  66. data/lib/deprec/recipes/rails.rb +330 -0
  67. data/lib/deprec/recipes/redhat_cluster.rb +228 -0
  68. data/lib/deprec/recipes/redis.rb +90 -0
  69. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  70. data/lib/deprec/recipes/ruby/ree.rb +40 -0
  71. data/lib/deprec/recipes/rvm.rb +32 -0
  72. data/lib/deprec/recipes/s3utils.rb +63 -0
  73. data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +105 -0
  74. data/lib/deprec/recipes/sphinx/ultrasphinx.rb +86 -0
  75. data/lib/deprec/recipes/ssh.rb +147 -0
  76. data/lib/deprec/recipes/ssl.rb +56 -0
  77. data/lib/deprec/recipes/starling.rb +119 -0
  78. data/lib/deprec/recipes/svn.rb +171 -0
  79. data/lib/deprec/recipes/syslog.rb +63 -0
  80. data/lib/deprec/recipes/trac.rb.disabled +277 -0
  81. data/lib/deprec/recipes/tsung.rb +74 -0
  82. data/lib/deprec/recipes/ubuntu.rb +90 -0
  83. data/lib/deprec/recipes/users.rb +90 -0
  84. data/lib/deprec/recipes/utils.rb +58 -0
  85. data/lib/deprec/recipes/vnstat.rb +85 -0
  86. data/lib/deprec/recipes/web/apache.rb +143 -0
  87. data/lib/deprec/recipes/web/nginx.rb +172 -0
  88. data/lib/deprec/recipes/wordpress.rb.notworking +96 -0
  89. data/lib/deprec/recipes/wpmu.rb +103 -0
  90. data/lib/deprec/recipes/xen.rb +364 -0
  91. data/lib/deprec/recipes/xentools.rb +101 -0
  92. data/lib/deprec/recipes_minus_rails.rb +125 -0
  93. data/lib/deprec/templates/aoe/aoe-init +55 -0
  94. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  95. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  96. data/lib/deprec/templates/apache/ports.conf.erb +5 -0
  97. data/lib/deprec/templates/apache/status.conf.erb +17 -0
  98. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  99. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  100. data/lib/deprec/templates/chef/chef.json.erb +1 -0
  101. data/lib/deprec/templates/chef/solo.rb +2 -0
  102. data/lib/deprec/templates/collectd/collectd-init.d +153 -0
  103. data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
  104. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  105. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  106. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  107. data/lib/deprec/templates/drbd/drbd.conf.erb +531 -0
  108. data/lib/deprec/templates/glusterfs/glusterfsd-init.erb +95 -0
  109. data/lib/deprec/templates/gnbd_client/cluster.conf.erb +21 -0
  110. data/lib/deprec/templates/gnbd_client/clvm-default.erb +3 -0
  111. data/lib/deprec/templates/gnbd_client/cman-default.erb +6 -0
  112. data/lib/deprec/templates/gnbd_client/gnbdimports.conf.erb +1 -0
  113. data/lib/deprec/templates/gnbd_server/cluster.conf.erb +20 -0
  114. data/lib/deprec/templates/gnbd_server/clvm-default.erb +3 -0
  115. data/lib/deprec/templates/gnbd_server/cman-default.erb +6 -0
  116. data/lib/deprec/templates/gnbd_server/gnbd-server-default.erb +1 -0
  117. data/lib/deprec/templates/gnbd_server/gnbdexports.conf.erb +1 -0
  118. data/lib/deprec/templates/god/god-conf.erb +2 -0
  119. data/lib/deprec/templates/god/god-init.erb +47 -0
  120. data/lib/deprec/templates/haproxy/haproxy-init.d +120 -0
  121. data/lib/deprec/templates/haproxy/haproxy.cfg.erb +31 -0
  122. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  123. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  124. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  125. data/lib/deprec/templates/integrity/apache_vhost.erb +4 -0
  126. data/lib/deprec/templates/integrity/config.ru.erb +21 -0
  127. data/lib/deprec/templates/integrity/config.yml.erb +43 -0
  128. data/lib/deprec/templates/iptables/firewall-default.erb +13 -0
  129. data/lib/deprec/templates/iptables/firewall-init.erb +171 -0
  130. data/lib/deprec/templates/keepalived/keepalived.conf.erb +18 -0
  131. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  132. data/lib/deprec/templates/mongodb/mongodb-init.d +88 -0
  133. data/lib/deprec/templates/mongrel/apache_vhost.conf.erb +148 -0
  134. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  135. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  136. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  137. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  138. data/lib/deprec/templates/mongrel/nginx_vhost.conf.erb +41 -0
  139. data/lib/deprec/templates/monit/monit-init-script +104 -0
  140. data/lib/deprec/templates/monit/monitrc.erb +250 -0
  141. data/lib/deprec/templates/monit/nothing.monitrc +0 -0
  142. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  143. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  144. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  145. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  146. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  147. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  148. data/lib/deprec/templates/mysql_proxy/mysql-proxy-default.erb +4 -0
  149. data/lib/deprec/templates/nagios/README +32 -0
  150. data/lib/deprec/templates/nagios/cgi.cfg.erb +357 -0
  151. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  152. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  153. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  154. data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
  155. data/lib/deprec/templates/nagios/nagios.cfg.erb +1325 -0
  156. data/lib/deprec/templates/nagios/nrpe.cfg.erb +222 -0
  157. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  158. data/lib/deprec/templates/nagios/objects/commands.cfg.erb +265 -0
  159. data/lib/deprec/templates/nagios/objects/contacts.cfg.erb +89 -0
  160. data/lib/deprec/templates/nagios/objects/hosts.cfg.erb +114 -0
  161. data/lib/deprec/templates/nagios/objects/localhost.cfg.erb +116 -0
  162. data/lib/deprec/templates/nagios/objects/services.cfg.erb +165 -0
  163. data/lib/deprec/templates/nagios/objects/timeperiods.cfg.erb +94 -0
  164. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  165. data/lib/deprec/templates/network/hostname.erb +1 -0
  166. data/lib/deprec/templates/network/hosts.erb +2 -0
  167. data/lib/deprec/templates/network/interfaces.erb +18 -0
  168. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  169. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  170. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  171. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  172. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  173. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  174. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  175. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  176. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  177. data/lib/deprec/templates/passenger/apache_vhost.erb +29 -0
  178. data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
  179. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  180. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  181. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  182. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  183. data/lib/deprec/templates/postfix/main.cf.erb +36 -0
  184. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  185. data/lib/deprec/templates/redis/redis-conf.erb +132 -0
  186. data/lib/deprec/templates/redis/redis-init.erb +50 -0
  187. data/lib/deprec/templates/s3utils/s3cfg +35 -0
  188. data/lib/deprec/templates/s3utils/s3config.yml +3 -0
  189. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  190. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  191. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  192. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  193. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  194. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  195. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  196. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  197. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  198. data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
  199. data/lib/deprec/templates/syslog/syslogd.erb +13 -0
  200. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  201. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  202. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  203. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  204. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  205. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  206. data/lib/deprec/templates/tsung/tsung.xml.erb +47 -0
  207. data/lib/deprec/templates/vnstat/config.php +57 -0
  208. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  209. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  210. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  211. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  212. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  213. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  214. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  215. data/lib/deprec/templates/xentools/100-ubuntu-setup +26 -0
  216. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  217. data/lib/deprec/templates/xentools/30-disable-gettys +57 -0
  218. data/lib/deprec/templates/xentools/31-ubuntu-setup +32 -0
  219. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  220. data/lib/deprec/templates/xentools/98-custom +17 -0
  221. data/lib/deprec/templates/xentools/xen-tools.conf.erb +278 -0
  222. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  223. data/lib/deprec_cmd_completion.sh +26 -0
  224. data/lib/deprec_minus_rails.rb +12 -0
  225. data/lib/vmbuilder_plugins/all.rb +20 -0
  226. data/lib/vmbuilder_plugins/apt.rb +93 -0
  227. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  228. data/lib/vmbuilder_plugins/gem.rb +100 -0
  229. data/lib/vmbuilder_plugins/std.rb +203 -0
  230. metadata +304 -0
@@ -0,0 +1,20 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :lvm do
5
+
6
+ task :pvdisplay do
7
+ sudo "pvdisplay"
8
+ end
9
+
10
+ task :vgdisplay do
11
+ sudo "vgdisplay"
12
+ end
13
+
14
+ task :lvdisplay do
15
+ sudo "lvdisplay"
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
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
+ version = 'memcached-1.2.2'
28
+ set :src_package, {
29
+ :file => version + '.tar.gz',
30
+ :md5sum => 'a08851f7fa7b15e92ee6320b7a79c321 memcached-1.2.2.tar.gz',
31
+ :dir => version,
32
+ :url => "http://www.danga.com/memcached/dist/#{version}.tar.gz",
33
+ :unpack => "tar zxf #{version}.tar.gz;",
34
+ :configure => %w{
35
+ ./configure
36
+ --prefix=/usr/local
37
+ ;
38
+ }.reject{|arg| arg.match '#'}.join(' '),
39
+ :make => 'make;',
40
+ :install => 'make install;',
41
+ :post_install => 'install -b scripts/memcached-init /etc/init.d/memcached;'
42
+ }
43
+ apt.install( {:base => %w(libevent-dev)}, :stable )
44
+ deprec.download_src(src_package, src_dir)
45
+ deprec.install_from_src(src_package, src_dir)
46
+ end
47
+ end end
48
+
49
+ end
@@ -0,0 +1,94 @@
1
+ # Copyright 2006-2010 by joost@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :mongodb do
5
+
6
+ SRC_PACKAGES[:mongodb] = {
7
+ :filename => 'mongodb-src-r1.4.0.tar.gz',
8
+ :dir => 'mongodb-src-r1.4.0',
9
+ :url => "http://downloads.mongodb.org/src/mongodb-src-r1.4.0.tar.gz",
10
+ :unpack => "tar zxf mongodb-src-r1.4.0.tar.gz;",
11
+ :configure => '',
12
+ :make => 'scons all;',
13
+ :install => 'scons --prefix=/usr/local/mongo install;'
14
+ }
15
+
16
+ # Installs MongoDB on Ubuntu 8.04.
17
+ # Still gives:
18
+ # warning built with boost version 1.34 or older - limited concurrency
19
+ desc "install MongoDB"
20
+ task :install, :roles => :mongodb do
21
+ install_deps
22
+ deprec2.download_src(SRC_PACKAGES[:mongodb], src_dir)
23
+ deprec2.install_from_src(SRC_PACKAGES[:mongodb], src_dir)
24
+ sudo 'mkdir -p /var/lib/mongodb' # Data dir, also pid/lock file is in there (see init.d script)
25
+ end
26
+
27
+ # Install dependencies for MongoDB
28
+ task :install_deps, :roles => :mongodb do
29
+ # See: http://www.mongodb.org/display/DOCS/Building+for+Linux
30
+ apt.install( {:base => %w(tcsh git-core scons g++)}, :stable )
31
+ apt.install( {:base => %w(libpcre++-dev libboost-dev libreadline-dev xulrunner-1.9-dev)}, :stable )
32
+ apt.install( {:base => %w(libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev)}, :stable )
33
+ end
34
+
35
+ SYSTEM_CONFIG_FILES[:mongodb] = [
36
+
37
+ {:template => "mongodb-init.d",
38
+ :path => '/etc/init.d/mongodb',
39
+ :mode => 0755,
40
+ :owner => 'root:root'}
41
+
42
+ ]
43
+
44
+ PROJECT_CONFIG_FILES[:mongodb] = []
45
+
46
+ desc "Generate configuration files for mongodb from template(s)"
47
+ task :config_gen do
48
+ config_gen_system
49
+ end
50
+
51
+ task :config_gen_system do
52
+ SYSTEM_CONFIG_FILES[:mongodb].each do |file|
53
+ deprec2.render_template(:mongodb, file)
54
+ end
55
+ end
56
+
57
+ desc 'Deploy configuration files for mongodb'
58
+ task :config, :roles => :mongodb do
59
+ config_system
60
+ end
61
+
62
+ task :config_system, :roles => :mongodb do
63
+ deprec2.append_to_file_if_missing('/etc/profile', 'export PATH=$PATH:/usr/local/mongo/bin')
64
+ deprec2.push_configs(:mongodb, SYSTEM_CONFIG_FILES[:mongodb])
65
+ end
66
+
67
+ desc 'Start mongodb via init.d script'
68
+ task :start, :roles => :mongodb do
69
+ run "#{sudo} /etc/init.d/mongodb start"
70
+ end
71
+
72
+ desc 'Stop mongodb via init.d script'
73
+ task :stop, :roles => :mongodb do
74
+ run "#{sudo} /etc/init.d/mongodb stop"
75
+ end
76
+
77
+ desc 'Restart mongodb via init.d script'
78
+ task :restart, :roles => :mongodb do
79
+ run "#{sudo} /etc/init.d/mongodb restart"
80
+ end
81
+
82
+ desc 'Activate mongodb init.d script to start at boot'
83
+ task :activate, :roles => :mongodb do
84
+ run "#{sudo} update-rc.d mongodb defaults"
85
+ end
86
+
87
+ desc 'Deactivate mongodb init.d script to NOT start at boot'
88
+ task :deactivate, :roles => :mongodb do
89
+ run "#{sudo} update-rc.d -f mongodb remove"
90
+ end
91
+
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,135 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :monit do
5
+
6
+ # We're using monit primarily to control Mongrel processes so
7
+ # the tasks are restricted to :app. You may with to use it for
8
+ # other processes. In this case, specify HOSTS=hostname on the
9
+ # command line or use:
10
+ # for_roles(:role_name) { top.deprec.monit.task_name}
11
+ # in your recipes.
12
+
13
+ set :monit_user, 'monit'
14
+ set :monit_group, 'monit'
15
+ set :monit_confd_dir, '/etc/monit.d'
16
+
17
+ set :monit_check_interval, 60
18
+ set :monit_log, 'syslog facility log_daemon'
19
+ set :monit_mailserver, nil
20
+ set :monit_mail_from, 'monit@deprec.enabled.slice'
21
+ set :monit_alert_recipients, %w(root@localhost)
22
+ set :monit_timeout_recipients, %w(root@localhost)
23
+ set :monit_webserver_enabled, true
24
+ set :monit_webserver_port, 2812
25
+ set :monit_webserver_address, 'localhost'
26
+ set :monit_webserver_allowed_hosts_and_networks, %w(localhost)
27
+ set :monit_webserver_auth_user, 'admin'
28
+ set :monit_webserver_auth_pass, 'monit'
29
+ set :use_monit, true # FIXME: should be generic namespace monitoring, with :none option
30
+
31
+ # Upstream changes: http://www.tildeslash.com/monit/dist/CHANGES.txt
32
+ # Ubuntu package version = monit-4.8.1
33
+ SRC_PACKAGES[:monit] = {
34
+ :md5sum => "4bbd3845ae1cbab13ec211824e0486dc monit-5.1.1.tar.gz",
35
+ :url => "http://mmonit.com/monit/dist/monit-5.1.1.tar.gz"
36
+ }
37
+
38
+ desc "Install monit"
39
+ task :install, :roles => :app do
40
+ install_deps
41
+ deprec2.download_src(SRC_PACKAGES[:monit], src_dir)
42
+ deprec2.install_from_src(SRC_PACKAGES[:monit], src_dir)
43
+ # Initial push of system files - not kept locally
44
+ SYSTEM_CONFIG_FILES[:monit].each do |file|
45
+ deprec2.render_template(:monit, file.merge(:remote=>true))
46
+ end
47
+ activate
48
+ end
49
+
50
+ # install dependencies for monit
51
+ task :install_deps, :roles => :app do
52
+ apt.install( {:base => %w(flex bison libssl-dev)}, :stable )
53
+ end
54
+
55
+ SYSTEM_CONFIG_FILES[:monit] = [
56
+
57
+ {:template => 'monit-init-script',
58
+ :path => '/etc/init.d/monit',
59
+ :mode => 0755,
60
+ :owner => 'root:root'},
61
+
62
+ {:template => 'monitrc.erb',
63
+ :path => "/etc/monitrc",
64
+ :mode => 0700,
65
+ :owner => 'root:root'},
66
+
67
+ {:template => 'nothing.monitrc',
68
+ :path => "/etc/monit.d/nothing.monitrc",
69
+ :mode => 0700,
70
+ :owner => 'root:root'}
71
+ ]
72
+
73
+ desc <<-DESC
74
+ Generate monit config from template. Note that this does not
75
+ push the config to the server, it merely generates required
76
+ configuration files. These should be kept under source control.
77
+ The can be pushed to the server with the :config task.
78
+ DESC
79
+ task :config_gen do
80
+ SYSTEM_CONFIG_FILES[:monit].each do |file|
81
+ deprec2.render_template(:monit, file)
82
+ end
83
+ end
84
+
85
+ desc "Push monit config files to server"
86
+ task :config, :roles => :app do
87
+ deprec2.push_configs(:monit, SYSTEM_CONFIG_FILES[:monit])
88
+ end
89
+
90
+ desc "Start Monit"
91
+ task :start, :roles => :app do
92
+ send(run_method, "/etc/init.d/monit start")
93
+ end
94
+
95
+ desc "Stop Monit"
96
+ task :stop, :roles => :app do
97
+ send(run_method, "/etc/init.d/monit stop")
98
+ end
99
+
100
+ desc "Restart Monit"
101
+ task :restart, :roles => :app do
102
+ send(run_method, "/etc/init.d/monit restart")
103
+ end
104
+
105
+ desc "Reload Monit"
106
+ task :reload, :roles => :app do
107
+ send(run_method, "/etc/init.d/monit reload")
108
+ end
109
+
110
+ desc <<-DESC
111
+ Activate monit start scripts on server.
112
+ Setup server to start monit on boot.
113
+ DESC
114
+ task :activate, :roles => :app do
115
+ send(run_method, "update-rc.d monit defaults")
116
+ end
117
+
118
+ desc <<-DESC
119
+ Dectivate monit start scripts on server.
120
+ Setup server to start monit on boot.
121
+ DESC
122
+ task :deactivate, :roles => :app do
123
+ send(run_method, "update-rc.d -f monit remove")
124
+ end
125
+
126
+ task :backup do
127
+ # there's nothing to backup for monit
128
+ end
129
+
130
+ task :restore do
131
+ # there's nothing to restore for monit
132
+ end
133
+
134
+ end end
135
+ end
@@ -0,0 +1,67 @@
1
+ # Copyright 2009-2010 by le1t0@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :mysql_proxy do
5
+
6
+ set :mysql_proxy_backend_servers, [ '192.168.0.1' ]
7
+ set :mysql_proxy_read_only_backend_servers, [ '192.168.0.2', '192.168.0.3' ]
8
+
9
+ desc "Install mysql_proxy on server"
10
+ task :install, :roles => :proxy do
11
+ install_deps
12
+ config
13
+ reactivate
14
+ end
15
+
16
+ task :install_deps, :roles => :proxy do
17
+ apt.install( {:base => %w(mysql-proxy)}, :stable )
18
+ end
19
+
20
+ SYSTEM_CONFIG_FILES[:mysql_proxy] = [
21
+ {:template => 'mysql-proxy-default.erb',
22
+ :path => '/etc/default/mysql-proxy',
23
+ :mode => 0644,
24
+ :owner => 'root:root'}
25
+ ]
26
+
27
+ desc "Generate config files for mysql_proxy"
28
+ task :config_gen do
29
+ SYSTEM_CONFIG_FILES[:mysql_proxy].each do |file|
30
+ deprec2.render_template(:mysql_proxy, file)
31
+ end
32
+ end
33
+
34
+ desc "Push mysql_proxy config files to server"
35
+ task :config, :roles => :proxy do
36
+ deprec2.push_configs(:mysql_proxy, SYSTEM_CONFIG_FILES[:mysql_proxy])
37
+ end
38
+
39
+ task :start, :roles => :proxy do
40
+ sudo "/etc/init.d/mysql-proxy start"
41
+ end
42
+
43
+ task :stop, :roles => :proxy do
44
+ sudo "/etc/init.d/mysql-proxy stop"
45
+ end
46
+
47
+ task :restart do
48
+ stop
49
+ start
50
+ end
51
+
52
+ task :activate, :roles => :proxy do
53
+ sudo "update-rc.d mysql-proxy defaults"
54
+ end
55
+
56
+ task :deactivate, :roles => :proxy do
57
+ sudo "update-rc.d -f mysql-proxy remove"
58
+ end
59
+
60
+ task :reactivate do
61
+ deactivate
62
+ activate
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,361 @@
1
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :nagios do
5
+
6
+ set :nagios_user, 'nagios'
7
+ set :nagios_group, 'nagios'
8
+ set(:nagios_host) { Capistrano::CLI.ui.ask "Enter hostname of nagios server" }
9
+ set(:nagios_ip) { Capistrano::CLI.ui.ask "Enter ip address of nagios server" }
10
+ set(:nagios_admin_pass) { Capistrano::CLI.ui.ask "Enter password for nagiosadmin user" }
11
+ set :nagios_cmd_group, 'nagcmd' # Submit external commands through the web interface
12
+ set :nagios_htpasswd_file, '/usr/local/nagios/etc/htpasswd.users'
13
+ # default :application, 'nagios'
14
+ set :nagios_ssh_key, nil
15
+
16
+ SRC_PACKAGES[:nagios] = {
17
+ :url => "http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz",
18
+ :md5sum => "3566167cc60ddeaad34e7d2e26ed4a58 nagios-3.2.0.tar.gz",
19
+ :configure => "./configure --with-command-group=nagcmd;",
20
+ :make => 'make all;',
21
+ :install => 'make install install-init install-commandmode install-webconf;'
22
+ }
23
+
24
+ desc "Install and configure Nagios server"
25
+ task :setup_server, :roles => :nagios do
26
+ install
27
+ top.deprec.nagios_plugins.install
28
+ top.deprec.nrpe.install
29
+ config_gen
30
+ config
31
+ end
32
+
33
+ desc "Setup client"
34
+ task :setup_client do
35
+ top.deprec.nagios_plugins.install
36
+ top.deprec.nrpe.install
37
+ top.deprec.nrpe.config
38
+ end
39
+
40
+ desc "Install nagios"
41
+ task :install, :roles => :nagios do
42
+ install_deps
43
+ create_nagios_user
44
+ deprec2.download_src(SRC_PACKAGES[:nagios], src_dir)
45
+ deprec2.install_from_src(SRC_PACKAGES[:nagios], src_dir)
46
+ end
47
+
48
+ # Install dependencies for nagios
49
+ task :install_deps, :roles => :nagios do
50
+ apt.install( {:base => %w(apache2 mailx postfix libapache2-mod-php5 libgd2-xpm-dev)}, :stable )
51
+ end
52
+
53
+ task :create_nagios_user, :roles => :nagios do
54
+ deprec2.groupadd(nagios_group)
55
+ deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
56
+ # deprec2.add_user_to_group(nagios_user, apache_user)
57
+ deprec2.groupadd(nagios_cmd_group)
58
+ deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
59
+ deprec2.add_user_to_group(apache_user, nagios_cmd_group)
60
+ end
61
+
62
+ desc "Grant a user access to the web interface"
63
+ task :htpass, :roles => :nagios do
64
+ target_user = Capistrano::CLI.ui.ask "Userid" do |q|
65
+ q.default = 'nagiosadmin'
66
+ end
67
+ system "htpasswd config/nagios/usr/local/nagios/etc/htpasswd.users #{target_user}"
68
+ end
69
+
70
+ # desc "Set password for web based access"
71
+ # task :htpass do
72
+ # target_user = Capistrano::CLI.ui.ask "Userid" do |q|
73
+ # q.default = 'nagiosadmin'
74
+ # end
75
+ # newpass = Capistrano::CLI.ui.ask "new password" do |q|
76
+ # q.echo = false
77
+ # end
78
+ # sudo "htpasswd -b #{htpasswd_file} #{target_user} #{newpass}"
79
+ # end
80
+
81
+ SYSTEM_CONFIG_FILES[:nagios] = [
82
+
83
+ {:template => 'cgi.cfg.erb',
84
+ :path => '/usr/local/nagios/etc/cgi.cfg',
85
+ :mode => 0664,
86
+ :owner => 'nagios:nagios'},
87
+
88
+ {:template => 'htpasswd.users',
89
+ :path => '/usr/local/nagios/etc/htpasswd.users',
90
+ :mode => 0660,
91
+ :owner => 'nagios:www-data'},
92
+
93
+ {:template => 'nagios.cfg.erb',
94
+ :path => '/usr/local/nagios/etc/nagios.cfg',
95
+ :mode => 0664,
96
+ :owner => 'nagios:nagios'},
97
+
98
+ {:template => 'resource.cfg.erb',
99
+ :path => '/usr/local/nagios/etc/resource.cfg',
100
+ :mode => 0660,
101
+ :owner => 'nagios:nagios'},
102
+
103
+ {:template => 'objects/commands.cfg.erb',
104
+ :path => '/usr/local/nagios/etc/objects/commands.cfg',
105
+ :mode => 0664,
106
+ :owner => 'nagios:nagios'},
107
+
108
+ {:template => 'objects/contacts.cfg.erb',
109
+ :path => '/usr/local/nagios/etc/objects/contacts.cfg',
110
+ :mode => 0664,
111
+ :owner => 'nagios:nagios'},
112
+
113
+ {:template => 'objects/hosts.cfg.erb',
114
+ :path => '/usr/local/nagios/etc/objects/hosts.cfg',
115
+ :mode => 0664,
116
+ :owner => 'nagios:nagios'},
117
+
118
+ {:template => 'objects/localhost.cfg.erb',
119
+ :path => '/usr/local/nagios/etc/objects/localhost.cfg',
120
+ :mode => 0664,
121
+ :owner => 'nagios:nagios'},
122
+
123
+ {:template => 'objects/services.cfg.erb',
124
+ :path => '/usr/local/nagios/etc/objects/services.cfg',
125
+ :mode => 0664,
126
+ :owner => 'nagios:nagios'},
127
+
128
+ {:template => 'objects/timeperiods.cfg.erb',
129
+ :path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
130
+ :mode => 0664,
131
+ :owner => 'nagios:nagios'}
132
+
133
+ ]
134
+
135
+ desc "Generate configuration file(s) for nagios from template(s)"
136
+ task :config_gen do
137
+ SYSTEM_CONFIG_FILES[:nagios].each do |file|
138
+ deprec2.render_template(:nagios, file)
139
+ end
140
+ end
141
+
142
+ desc "Push nagios config files to server"
143
+ task :config, :roles => :nagios do
144
+ default :application, 'nagios'
145
+ deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nagios])
146
+ config_check
147
+ restart
148
+ end
149
+
150
+ desc "Run Nagios config check"
151
+ task :config_check, :roles => :nagios do
152
+ send(run_method, "/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg")
153
+ end
154
+
155
+ # desc "Set Nagios to start on boot"
156
+ # task :activate, :roles => :nagios do
157
+ # send(run_method, "update-rc.d nagios defaults")
158
+ # sudo "a2ensite nagios"
159
+ # top.deprec.apache.reload
160
+ # end
161
+ #
162
+ # desc "Set Nagios to not start on boot"
163
+ # task :deactivate, :roles => :nagios do
164
+ # send(run_method, "update-rc.d -f nagios remove")
165
+ # sudo "a2dissite nagios"
166
+ # top.deprec.apache.reload
167
+ # end
168
+
169
+ # Control
170
+
171
+ desc "Start Nagios"
172
+ task :start, :roles => :nagios do
173
+ send(run_method, "/etc/init.d/nagios start")
174
+ end
175
+
176
+ desc "Stop Nagios"
177
+ task :stop, :roles => :nagios do
178
+ send(run_method, "/etc/init.d/nagios stop")
179
+ end
180
+
181
+ desc "Restart Nagios"
182
+ task :restart, :roles => :nagios do
183
+ send(run_method, "/etc/init.d/nagios restart")
184
+ end
185
+
186
+ desc "Reload Nagios"
187
+ task :reload, :roles => :nagios do
188
+ send(run_method, "/etc/init.d/nagios reload")
189
+ end
190
+
191
+ task :backup, :roles => :web do
192
+ # not yet implemented
193
+ end
194
+
195
+ task :restore, :roles => :web do
196
+ # not yet implemented
197
+ end
198
+
199
+ end
200
+
201
+ SRC_PACKAGES[:nagios_plugins] = {
202
+ :url => "http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz",
203
+ :md5sum => "a1835a48a777863ed2583de3c82446a9 nagios-plugins-1.4.14.tar.gz",
204
+ :configure => "./configure --with-nagios-user=#{nagios_user} --with-nagios-group=#{nagios_group};",
205
+ }
206
+
207
+ namespace :nagios_plugins do
208
+
209
+ desc "Install nagios plugins"
210
+ task :install do
211
+ install_deps
212
+ create_nagios_user
213
+ deprec2.download_src(SRC_PACKAGES[:nagios_plugins], src_dir)
214
+ deprec2.install_from_src(SRC_PACKAGES[:nagios_plugins], src_dir)
215
+ end
216
+
217
+ desc "Install user plugins for nagios from config/nagios_plugins/plugins in user's project"
218
+ task :install_custom do
219
+ remote_path = File.join('/', 'usr', 'local', 'nagios', 'libexec')
220
+ plugins_path = File.join('config', 'nagios_plugins', 'plugins')
221
+ Dir.new(plugins_path).entries.each do |entry|
222
+ remote_plugin = File.join(remote_path, entry)
223
+ plugin = File.join(plugins_path, entry)
224
+ if File.file?(plugin)
225
+ std.su_put File.read(plugin), remote_plugin, '/tmp', :mode => 0755
226
+ end
227
+ end
228
+ end
229
+
230
+ desc "configure ssh + sudo access for nagios_user"
231
+ task :config_access do
232
+ deprec2.append_to_file_if_missing('/etc/sudoers', "#{nagios_user} ALL=(root) NOPASSWD:/usr/bin/killall")
233
+ deprec2.append_to_file_if_missing('/etc/sudoers', "#{nagios_user} ALL=(root) NOPASSWD:/bin/kill")
234
+ deprec2.append_to_file_if_missing('/etc/sudoers', "#{nagios_user} ALL=(root) NOPASSWD:/sbin/iptables")
235
+ deprec2.append_to_file_if_missing('/etc/sudoers', "#{nagios_user} ALL=(root) NOPASSWD:/bin/cat")
236
+ sudo "mkdir -p /home/#{nagios_user}/.ssh"
237
+ sudo "chmod 700 /home/#{nagios_user}/.ssh"
238
+ if nagios_ssh_key
239
+ sudo "echo '#{nagios_ssh_key}' >> /tmp/authorized_keys_file_for_nagios_user.tmp"
240
+ end
241
+ sudo "mv /tmp/authorized_keys_file_for_nagios_user.tmp /home/#{nagios_user}/.ssh/authorized_keys"
242
+ sudo "chmod 600 /home/#{nagios_user}/.ssh/authorized_keys"
243
+ sudo "chown -R nagios:nagios /home/#{nagios_user}/.ssh"
244
+ end
245
+
246
+ # Install dependencies for nagios plugins
247
+ task :install_deps do
248
+ apt.install( {:base => %w(libmysqlclient15-dev)}, :stable )
249
+ end
250
+
251
+ task :create_nagios_user do
252
+ deprec2.groupadd(nagios_group)
253
+ deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
254
+ # deprec2.add_user_to_group(nagios_user, apache_user)
255
+ deprec2.groupadd(nagios_cmd_group)
256
+ deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
257
+ deprec2.add_user_to_group(apache_user, nagios_cmd_group)
258
+ end
259
+
260
+
261
+ end
262
+
263
+
264
+ namespace :nrpe do
265
+
266
+ default :nrpe_enable_command_args, false # set to true to compile nrpe to accept arguments
267
+ # note that you'll need to set it before these recipes are loaded (e.g. in .caprc)
268
+
269
+ SRC_PACKAGES[:nrpe] = {
270
+ :url => "http://downloads.sourceforge.net/nagios/nrpe-2.12.tar.gz",
271
+ :md5sum => "b2d75e2962f1e3151ef58794d60c9e97 nrpe-2.12.tar.gz",
272
+ :configure => "./configure --with-nagios-user=#{nagios_user} --with-nagios-group=#{nagios_group} #{ '--enable-command-args' if nrpe_enable_command_args};",
273
+ :make => 'make all;',
274
+ :install => 'make install-plugin; make install-daemon; make install-daemon-config;'
275
+ }
276
+
277
+ desc 'Install NRPE'
278
+ task :install do
279
+ install_deps
280
+ create_nagios_user
281
+ deprec2.download_src(SRC_PACKAGES[:nrpe], src_dir)
282
+ deprec2.install_from_src(SRC_PACKAGES[:nrpe], src_dir)
283
+ # XXX this should only be run on the nrpe clients
284
+ # XXX currently it's run on the nagios server too
285
+ # XXX shouldn't do any harm but we should split them up later
286
+ deprec2.append_to_file_if_missing('/etc/services', 'nrpe 5666/tcp # NRPE')
287
+ config
288
+ end
289
+
290
+ task :install_deps do
291
+ apt.install( {:base => %w(xinetd libssl-dev openssl)}, :stable )
292
+ end
293
+
294
+ task :create_nagios_user do
295
+ deprec2.groupadd(nagios_group)
296
+ deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
297
+ # deprec2.add_user_to_group(nagios_user, apache_user)
298
+ deprec2.groupadd(nagios_cmd_group)
299
+ deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
300
+ deprec2.add_user_to_group(apache_user, nagios_cmd_group)
301
+ end
302
+
303
+ SYSTEM_CONFIG_FILES[:nrpe] = [
304
+
305
+ {:template => 'nrpe.xinetd.erb',
306
+ :path => "/etc/xinetd.d/nrpe",
307
+ :mode => 0644,
308
+ :owner => 'root:root'},
309
+
310
+ {:template => 'nrpe.cfg.erb',
311
+ :path => "/usr/local/nagios/etc/nrpe.cfg",
312
+ :mode => 0644,
313
+ :owner => 'nagios:nagios'}, # XXX hard coded file owner is bad...
314
+ # It's done here because we aren't using
315
+ # lazy eval in hash constant.
316
+ {:template => "check_mongrel_cluster.rb",
317
+ :path => '/usr/local/nagios/libexec/check_mongrel_cluster.rb',
318
+ :mode => 0755,
319
+ :owner => 'root:root'},
320
+
321
+ {:template => "check_linux_free_memory.pl",
322
+ :path => '/usr/local/nagios/libexec/check_linux_free_memory.pl',
323
+ :mode => 0755,
324
+ :owner => 'root:root'}
325
+
326
+ ]
327
+
328
+ desc "Generate configuration file(s) for nrpe from template(s)"
329
+ task :config_gen do
330
+ SYSTEM_CONFIG_FILES[:nrpe].each do |file|
331
+ deprec2.render_template(:nagios, file)
332
+ end
333
+ end
334
+
335
+ desc "Push nrpe config files to server"
336
+ task :config do
337
+ deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nrpe])
338
+ # XXX should really only do this on targets
339
+ sudo "/etc/init.d/xinetd stop"
340
+ sudo "/etc/init.d/xinetd start"
341
+ end
342
+
343
+ desc "Test whether NRPE is listening on client"
344
+ task :test_local do
345
+ run "/usr/local/nagios/libexec/check_nrpe -H localhost"
346
+ end
347
+
348
+ desc "Test whether nagios server can query client via NRPE"
349
+ task :test_remote, :roles => :nagios do
350
+ target_host = Capistrano::CLI.ui.ask "target hostname"
351
+ run "/usr/local/nagios/libexec/check_nrpe -H #{target_host}"
352
+ end
353
+
354
+ end
355
+
356
+ # PNP4nagios
357
+ # http://downloads.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz?use_mirror=internode
358
+
359
+
360
+ end
361
+ end