deprec 1.9.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGELOG +280 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +152 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +128 -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/{README.quickstart → deprec-1.x/deprec-1.x.quickstart} +4 -1
  12. data/docs/{building_edge_capistrano.txt → deprec-1.x/notes.txt} +6 -3
  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 +8 -1
  19. data/lib/deprec/capistrano_extensions.rb +442 -0
  20. data/lib/deprec/recipes.rb +50 -233
  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 +197 -0
  24. data/lib/deprec/recipes/apt_mirror.rb +99 -0
  25. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/db/mysql.rb +144 -0
  28. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  29. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  30. data/lib/deprec/recipes/ddclient.rb +51 -0
  31. data/lib/deprec/recipes/deprec.rb +199 -0
  32. data/lib/deprec/recipes/deprecated.rb +71 -0
  33. data/lib/deprec/recipes/example.rb +115 -0
  34. data/lib/deprec/recipes/git.rb +97 -0
  35. data/lib/deprec/recipes/gitosis.rb +48 -0
  36. data/lib/deprec/recipes/heartbeat.rb +138 -0
  37. data/lib/deprec/recipes/logrotate.rb +54 -0
  38. data/lib/deprec/recipes/lvm.rb +20 -0
  39. data/lib/deprec/recipes/memcache.rb +6 -2
  40. data/lib/deprec/recipes/monit.rb +143 -0
  41. data/lib/deprec/recipes/nagios.rb +305 -0
  42. data/lib/deprec/recipes/network.rb +93 -0
  43. data/lib/deprec/recipes/ntp.rb +103 -0
  44. data/lib/deprec/recipes/php.rb +58 -0
  45. data/lib/deprec/recipes/postfix.rb +115 -0
  46. data/lib/deprec/recipes/rails.rb +300 -55
  47. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  48. data/lib/deprec/recipes/ruby/ree.rb +41 -0
  49. data/lib/deprec/recipes/sphinx.rb +86 -0
  50. data/lib/deprec/recipes/ssh.rb +85 -18
  51. data/lib/deprec/recipes/ssl.rb +55 -0
  52. data/lib/deprec/recipes/starling.rb +119 -0
  53. data/lib/deprec/recipes/svn.rb +163 -183
  54. data/lib/deprec/recipes/trac.rb +239 -62
  55. data/lib/deprec/recipes/ubuntu.rb +18 -100
  56. data/lib/deprec/recipes/users.rb +90 -0
  57. data/lib/deprec/recipes/utils.rb +58 -0
  58. data/lib/deprec/recipes/vnstat.rb +85 -0
  59. data/lib/deprec/recipes/web/apache.rb +119 -0
  60. data/lib/deprec/recipes/web/nginx.rb +172 -0
  61. data/lib/deprec/recipes/wordpress.rb +96 -0
  62. data/lib/deprec/recipes/wpmu.rb +103 -0
  63. data/lib/deprec/recipes/xen.rb +267 -0
  64. data/lib/deprec/recipes/xentools.rb +75 -0
  65. data/lib/deprec/templates/aoe/aoe-init +55 -0
  66. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  67. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  68. data/lib/deprec/templates/apt/sources.list +18 -0
  69. data/lib/deprec/templates/apt_mirror/apt-mirror-cron +4 -0
  70. data/lib/deprec/templates/apt_mirror/mirror.list +33 -0
  71. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  72. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  73. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  74. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  75. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  76. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  77. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  78. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  79. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  80. data/lib/deprec/templates/mongrel/apache_vhost.erb +148 -0
  81. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  82. data/lib/deprec/{third_party/mongrel_cluster/resources/mongrel_cluster → templates/mongrel/mongrel_cluster-init-script} +19 -6
  83. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  84. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  85. data/lib/deprec/templates/mongrel/nginx_vhost.erb +41 -0
  86. data/lib/deprec/templates/monit/monit-init-script +104 -0
  87. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  88. data/lib/deprec/templates/monit/nothing +0 -0
  89. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  90. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  91. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  92. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  93. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  94. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  95. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  96. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  97. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  98. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  99. data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
  100. data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
  101. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  102. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  103. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  104. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  105. data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
  106. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  107. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  108. data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
  109. data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
  110. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  111. data/lib/deprec/templates/network/hostname.erb +1 -0
  112. data/lib/deprec/templates/network/hosts.erb +2 -0
  113. data/lib/deprec/templates/network/interfaces.erb +18 -0
  114. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  115. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  116. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  117. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  118. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  119. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  120. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  121. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  122. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  123. data/lib/deprec/templates/passenger/apache_vhost.erb +21 -0
  124. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  125. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  126. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  127. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  128. data/lib/deprec/templates/{postfix_main.conf → postfix/main.cf.erb} +6 -8
  129. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  130. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  131. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  132. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  133. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  134. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  135. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  136. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  137. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  138. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  139. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  140. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  141. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  142. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  143. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  144. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  145. data/lib/deprec/templates/vnstat/config.php +57 -0
  146. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  147. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  148. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  149. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  150. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  151. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  152. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  153. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  154. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  155. data/lib/deprec/templates/xentools/xen-tools.conf.erb +276 -0
  156. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  157. data/lib/deprec_cmd_completion.sh +26 -0
  158. data/lib/vmbuilder_plugins/all.rb +20 -0
  159. data/lib/vmbuilder_plugins/apt.rb +93 -0
  160. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  161. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/gem.rb +10 -17
  162. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/std.rb +69 -19
  163. metadata +204 -55
  164. data/bin/deprec +0 -35
  165. data/docs/README.slicehost +0 -14
  166. data/docs/README.svn_trac +0 -19
  167. data/lib/deprec/capistrano_extensions/actor_extensions.rb +0 -89
  168. data/lib/deprec/capistrano_extensions/cli_extensions.rb +0 -38
  169. data/lib/deprec/capistrano_extensions/deprec_extensions.rb +0 -137
  170. data/lib/deprec/generators/deprec/USAGE +0 -11
  171. data/lib/deprec/generators/deprec/deprec_generator.rb +0 -24
  172. data/lib/deprec/generators/deprec/templates/deploy.rb +0 -90
  173. data/lib/deprec/generators/loader.rb +0 -20
  174. data/lib/deprec/recipes/apache.rb +0 -91
  175. data/lib/deprec/recipes/cache_svn.rb +0 -74
  176. data/lib/deprec/recipes/vmware.rb +0 -114
  177. data/lib/deprec/templates/trac.ini.erb +0 -106
  178. data/lib/deprec/third_party/THIRD_PARTY_README +0 -12
  179. data/lib/deprec/third_party/mongrel_cluster/LICENSE +0 -506
  180. data/lib/deprec/third_party/mongrel_cluster/recipes.rb +0 -96
  181. data/lib/deprec/third_party/railsmachine/LICENSE +0 -506
  182. data/lib/deprec/third_party/railsmachine/recipes/apache.rb +0 -92
  183. data/lib/deprec/third_party/railsmachine/recipes/mysql.rb +0 -73
  184. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd-ssl.conf +0 -80
  185. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd.conf +0 -57
  186. data/lib/deprec/third_party/vmbuilder/plugins.rb +0 -8
  187. data/lib/deprec/third_party/vmbuilder/plugins/apt.rb +0 -144
  188. data/resources/capistrano_include_dotfiles.patch +0 -17
@@ -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
@@ -1,5 +1,8 @@
1
- Capistrano.configuration(:must_exist).load do
2
-
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
+
3
6
  set :memcache_ip, '127.0.0.1'
4
7
  set :memcache_port, 11211
5
8
  set :memcache_memory, 256
@@ -41,5 +44,6 @@ Capistrano.configuration(:must_exist).load do
41
44
  deprec.download_src(src_package, src_dir)
42
45
  deprec.install_from_src(src_package, src_dir)
43
46
  end
47
+ end end
44
48
 
45
49
  end
@@ -0,0 +1,143 @@
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
+
30
+ # Upstream changes: http://www.tildeslash.com/monit/dist/CHANGES.txt
31
+ # Ubuntu package version = monit-4.8.1
32
+ SRC_PACKAGES[:monit] = {
33
+ :filename => 'monit-4.10.1.tar.gz',
34
+ :md5sum => "d3143b0bbd79b53f1b019d2fc1dae656 monit-4.10.1.tar.gz",
35
+ :dir => 'monit-4.10.1',
36
+ :url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz",
37
+ :unpack => "tar zxf monit-4.10.1.tar.gz;",
38
+ :configure => %w(
39
+ ./configure
40
+ ;
41
+ ).reject{|arg| arg.match '#'}.join(' '),
42
+ :make => 'make;',
43
+ :install => 'make install;'
44
+ }
45
+
46
+ desc "Install monit"
47
+ task :install, :roles => :app do
48
+ install_deps
49
+ deprec2.download_src(SRC_PACKAGES[:monit], src_dir)
50
+ deprec2.install_from_src(SRC_PACKAGES[:monit], src_dir)
51
+ # Initial push of system files - not kept locally
52
+ SYSTEM_CONFIG_FILES[:monit].each do |file|
53
+ deprec2.render_template(:monit, file.merge(:remote=>true))
54
+ end
55
+ activate
56
+ end
57
+
58
+ # install dependencies for monit
59
+ task :install_deps, :roles => :app do
60
+ apt.install( {:base => %w(flex bison libssl-dev)}, :stable )
61
+ end
62
+
63
+ SYSTEM_CONFIG_FILES[:monit] = [
64
+
65
+ {:template => 'monit-init-script',
66
+ :path => '/etc/init.d/monit',
67
+ :mode => 0755,
68
+ :owner => 'root:root'},
69
+
70
+ {:template => 'monitrc.erb',
71
+ :path => "/etc/monitrc",
72
+ :mode => 0700,
73
+ :owner => 'root:root'},
74
+
75
+ {:template => 'nothing',
76
+ :path => "/etc/monit.d/nothing",
77
+ :mode => 0700,
78
+ :owner => 'root:root'}
79
+ ]
80
+
81
+ desc <<-DESC
82
+ Generate nginx config from template. Note that this does not
83
+ push the config to the server, it merely generates required
84
+ configuration files. These should be kept under source control.
85
+ The can be pushed to the server with the :config task.
86
+ DESC
87
+ task :config_gen do
88
+ SYSTEM_CONFIG_FILES[:monit].each do |file|
89
+ deprec2.render_template(:monit, file)
90
+ end
91
+ end
92
+
93
+ desc "Push monit config files to server"
94
+ task :config, :roles => :app do
95
+ deprec2.push_configs(:monit, SYSTEM_CONFIG_FILES[:monit])
96
+ end
97
+
98
+ desc "Start Monit"
99
+ task :start, :roles => :app do
100
+ send(run_method, "/etc/init.d/monit start")
101
+ end
102
+
103
+ desc "Stop Monit"
104
+ task :stop, :roles => :app do
105
+ send(run_method, "/etc/init.d/monit stop")
106
+ end
107
+
108
+ desc "Restart Monit"
109
+ task :restart, :roles => :app do
110
+ send(run_method, "/etc/init.d/monit restart")
111
+ end
112
+
113
+ desc "Reload Monit"
114
+ task :reload, :roles => :app do
115
+ send(run_method, "/etc/init.d/monit reload")
116
+ end
117
+
118
+ desc <<-DESC
119
+ Activate monit start scripts on server.
120
+ Setup server to start monit on boot.
121
+ DESC
122
+ task :activate, :roles => :app do
123
+ send(run_method, "update-rc.d monit defaults")
124
+ end
125
+
126
+ desc <<-DESC
127
+ Dectivate monit start scripts on server.
128
+ Setup server to start monit on boot.
129
+ DESC
130
+ task :deactivate, :roles => :app do
131
+ send(run_method, "update-rc.d -f monit remove")
132
+ end
133
+
134
+ task :backup do
135
+ # there's nothing to backup for monit
136
+ end
137
+
138
+ task :restore do
139
+ # there's nothing to restore for monit
140
+ end
141
+
142
+ end end
143
+ end
@@ -0,0 +1,305 @@
1
+ # Copyright 2006-2008 by Mike Bailey. 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_cmd_group, 'nagcmd' # Allow external commands to be submitted through the web interface
10
+ default :application, 'nagios'
11
+
12
+ SRC_PACKAGES[:nagios] = {
13
+ :url => "http://internap.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.2.tar.gz",
14
+ :md5sum => "008d71aac08660bc007f7130ea82ab80 nagios-3.0.2.tar.gz",
15
+ :configure => %w(
16
+ ./configure
17
+ --with-command-group=nagcmd
18
+ ;
19
+ ).reject{|arg| arg.match '#'}.join(' '),
20
+ :make => 'make all;',
21
+ :install => 'make install install-init install-commandmode'
22
+ }
23
+
24
+ desc "Install nagios"
25
+ task :install do
26
+ install_deps
27
+ create_nagios_user
28
+ deprec2.add_user_to_group(nagios_user, apache_user)
29
+ deprec2.mkdir('/usr/local/nagios/etc', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
30
+ deprec2.mkdir('/usr/local/nagios/objects', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
31
+ deprec2.download_src(SRC_PACKAGES[:nagios], src_dir)
32
+ deprec2.install_from_src(SRC_PACKAGES[:nagios], src_dir)
33
+ activate
34
+ end
35
+
36
+ task :create_nagios_user do
37
+ deprec2.groupadd(nagios_group)
38
+ deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
39
+ deprec2.groupadd(nagios_cmd_group)
40
+ deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
41
+ # Add apache user to nagios group to permit commands via web interface
42
+ deprec2.add_user_to_group(apache_user, nagios_cmd_group)
43
+ end
44
+
45
+ # Install dependencies for nagios
46
+ task :install_deps do
47
+ apt.install( {:base => %w(mailx)}, :stable )
48
+ end
49
+
50
+ SYSTEM_CONFIG_FILES[:nagios] = [
51
+
52
+ {:template => 'nagios.cfg.erb',
53
+ :path => '/usr/local/nagios/etc/nagios.cfg',
54
+ :mode => 0664,
55
+ :owner => 'nagios:nagios'},
56
+
57
+ {:template => 'resource.cfg.erb',
58
+ :path => '/usr/local/nagios/etc/resource.cfg',
59
+ :mode => 0660,
60
+ :owner => 'nagios:nagios'},
61
+
62
+ {:template => 'cgi.cfg.erb',
63
+ :path => '/usr/local/nagios/etc/cgi.cfg',
64
+ :mode => 0664,
65
+ :owner => 'nagios:nagios'},
66
+
67
+ {:template => 'htpasswd.users',
68
+ :path => '/usr/local/nagios/etc/htpasswd.users',
69
+ :mode => 0664,
70
+ :owner => 'nagios:nagios'},
71
+
72
+ {:template => 'templates.cfg.erb',
73
+ :path => '/usr/local/nagios/etc/objects/templates.cfg',
74
+ :mode => 0664,
75
+ :owner => 'nagios:nagios'},
76
+
77
+ {:template => 'commands.cfg.erb',
78
+ :path => '/usr/local/nagios/etc/objects/commands.cfg',
79
+ :mode => 0664,
80
+ :owner => 'nagios:nagios'},
81
+
82
+ {:template => 'timeperiods.cfg.erb',
83
+ :path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
84
+ :mode => 0664,
85
+ :owner => 'nagios:nagios'},
86
+
87
+ {:template => 'localhost.cfg.erb',
88
+ :path => '/usr/local/nagios/etc/objects/localhost.cfg',
89
+ :mode => 0664,
90
+ :owner => 'nagios:nagios'},
91
+
92
+ {:template => 'contacts.cfg.erb',
93
+ :path => '/usr/local/nagios/etc/objects/contacts.cfg',
94
+ :mode => 0664,
95
+ :owner => 'nagios:nagios'},
96
+
97
+ {:template => 'hosts.cfg.erb',
98
+ :path => '/usr/local/nagios/etc/objects/hosts.cfg',
99
+ :mode => 0664,
100
+ :owner => 'nagios:nagios'},
101
+
102
+ {:template => 'services.cfg.erb',
103
+ :path => '/usr/local/nagios/etc/objects/services.cfg',
104
+ :mode => 0664,
105
+ :owner => 'nagios:nagios'},
106
+
107
+ {:template => 'localhost.cfg.erb',
108
+ :path => '/usr/local/nagios/etc/objects/localhost.cfg',
109
+ :mode => 0664,
110
+ :owner => 'nagios:nagios'},
111
+
112
+ {:template => 'nagios_apache_vhost.conf.erb',
113
+ :path => "conf/nagios_apache_vhost.conf",
114
+ :mode => 0644,
115
+ :owner => 'root:root'}
116
+
117
+ ]
118
+
119
+ desc "Generate configuration file(s) for nagios from template(s)"
120
+ task :config_gen do
121
+ SYSTEM_CONFIG_FILES[:nagios].each do |file|
122
+ deprec2.render_template(:nagios, file)
123
+ end
124
+ end
125
+
126
+ desc "Push nagios config files to server"
127
+ task :config, :roles => :nagios do
128
+ set :application, 'nagios'
129
+ deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nagios])
130
+ sudo "ln -sf #{deploy_to}/nagios/conf/nagios_apache_vhost.conf /usr/local/apache2/conf/apps"
131
+ config_check
132
+ restart
133
+ end
134
+
135
+ desc "Run Nagios config check"
136
+ task :config_check, :roles => :nagios do
137
+ send(run_method, "/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg")
138
+ end
139
+
140
+ desc "Set Nagios to start on boot"
141
+ task :activate, :roles => :nagios do
142
+ send(run_method, "update-rc.d nagios defaults")
143
+ sudo "ln -sf #{deploy_to}/nagios/conf/nagios_apache_vhost.conf /usr/local/apache2/conf/apps"
144
+ end
145
+
146
+ desc "Set Nagios to not start on boot"
147
+ task :deactivate, :roles => :nagios do
148
+ send(run_method, "update-rc.d -f nagios remove")
149
+ link = "#{apache_vhost_dir}/nagios_#{application}.conf"
150
+ sudo "test -h #{link} && sudo unlink #{link} || true"
151
+ end
152
+
153
+ # Control
154
+
155
+ desc "Start Nagios"
156
+ task :start, :roles => :nagios do
157
+ send(run_method, "/etc/init.d/nagios start")
158
+ end
159
+
160
+ desc "Stop Nagios"
161
+ task :stop, :roles => :nagios do
162
+ send(run_method, "/etc/init.d/nagios stop")
163
+ end
164
+
165
+ desc "Restart Nagios"
166
+ task :restart, :roles => :nagios do
167
+ send(run_method, "/etc/init.d/nagios restart")
168
+ end
169
+
170
+ desc "Reload Nagios"
171
+ task :reload, :roles => :nagios do
172
+ send(run_method, "/etc/init.d/nagios reload")
173
+ end
174
+
175
+ task :backup, :roles => :web do
176
+ # not yet implemented
177
+ end
178
+
179
+ task :restore, :roles => :web do
180
+ # not yet implemented
181
+ end
182
+
183
+ #
184
+ # Service specific tasks
185
+ #
186
+
187
+ # XXX quick and dirty - clean up later
188
+ desc "Grant a user access to the web interface"
189
+ task :htpass, :roles => :nagios do
190
+ target_user = Capistrano::CLI.ui.ask "Userid" do |q|
191
+ q.default = 'nagiosadmin'
192
+ end
193
+ system "htpasswd config/nagios/usr/local/nagios/etc/htpasswd.users #{target_user}"
194
+ end
195
+
196
+ end
197
+
198
+ SRC_PACKAGES[:nagios_plugins] = {
199
+ :url => "http://downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.12.tar.gz",
200
+ :md5sum => "af68d00bbe2c39de02803d23e5eecca3 nagios-plugins-1.4.12.tar.gz",
201
+ :configure => "./configure --with-nagios-user=#{nagios_user} --with-nagios-group=#{nagios_group};",
202
+ }
203
+
204
+ namespace :nagios_plugins do
205
+
206
+ desc "Install nagios plugins"
207
+ task :install do
208
+ install_deps
209
+ top.deprec.nagios.create_nagios_user
210
+ deprec2.download_src(SRC_PACKAGES[:nagios_plugins], src_dir)
211
+ deprec2.install_from_src(SRC_PACKAGES[:nagios_plugins], src_dir)
212
+ end
213
+
214
+ # Install dependencies for nagios plugins
215
+ task :install_deps do
216
+ apt.install( {:base => %w(libmysqlclient15-dev)}, :stable )
217
+ end
218
+
219
+
220
+ end
221
+
222
+
223
+ namespace :nrpe do
224
+
225
+ default :nrpe_enable_command_args, false # set to true to compile nrpe to accept arguments
226
+ # note that you'll need to set it before these recipes are loaded (e.g. in .caprc)
227
+
228
+ SRC_PACKAGES[:nrpe] = {
229
+ :url => "http://downloads.sourceforge.net/nagios/nrpe-2.12.tar.gz",
230
+ :md5sum => "b2d75e2962f1e3151ef58794d60c9e97 nrpe-2.12.tar.gz",
231
+ :configure => "./configure --with-nagios-user=#{nagios_user} --with-nagios-group=#{nagios_group} #{ '--enable-command-args' if nrpe_enable_command_args};",
232
+ :make => 'make all;',
233
+ :install => 'make install-plugin; make install-daemon; make install-daemon-config;'
234
+ }
235
+
236
+ desc 'Install NRPE'
237
+ task :install do
238
+ install_deps
239
+ top.deprec.nagios.create_nagios_user
240
+ deprec2.download_src(SRC_PACKAGES[:nrpe], src_dir)
241
+ deprec2.install_from_src(SRC_PACKAGES[:nrpe], src_dir)
242
+ # XXX this should only be run on the nrpe clients
243
+ # XXX currently it's run on the nagios server too
244
+ # XXX shouldn't do any harm but we should split them up later
245
+ deprec2.append_to_file_if_missing('/etc/services', 'nrpe 5666/tcp # NRPE')
246
+ end
247
+
248
+ task :install_deps do
249
+ apt.install( {:base => %w(xinetd libssl-dev openssl)}, :stable )
250
+ end
251
+
252
+ SYSTEM_CONFIG_FILES[:nrpe] = [
253
+
254
+ {:template => 'nrpe.xinetd.erb',
255
+ :path => "/etc/xinetd.d/nrpe",
256
+ :mode => 0644,
257
+ :owner => 'root:root'},
258
+
259
+ {:template => 'nrpe.cfg.erb',
260
+ :path => "/usr/local/nagios/etc/nrpe.cfg",
261
+ :mode => 0644,
262
+ :owner => 'nagios:nagios'}, # XXX hard coded file owner is bad...
263
+ # It's done here because we aren't using
264
+ # lazy eval in hash constant.
265
+ {:template => "check_mongrel_cluster.rb",
266
+ :path => '/usr/local/nagios/libexec/check_mongrel_cluster.rb',
267
+ :mode => 0755,
268
+ :owner => 'root:root'},
269
+
270
+ {:template => "check_linux_free_memory.pl",
271
+ :path => '/usr/local/nagios/libexec/check_linux_free_memory.pl',
272
+ :mode => 0755,
273
+ :owner => 'root:root'}
274
+
275
+ ]
276
+
277
+ desc "Generate configuration file(s) for nrpe from template(s)"
278
+ task :config_gen do
279
+ SYSTEM_CONFIG_FILES[:nrpe].each do |file|
280
+ deprec2.render_template(:nagios, file)
281
+ end
282
+ end
283
+
284
+ desc "Push nrpe config files to server"
285
+ task :config do
286
+ deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nrpe])
287
+ # XXX should really only do this on targets
288
+ sudo "/etc/init.d/xinetd stop"
289
+ sudo "/etc/init.d/xinetd start"
290
+ end
291
+
292
+ task :test_local do
293
+ run "/usr/local/nagios/libexec/check_nrpe -H localhost"
294
+ end
295
+
296
+ task :test_remote, :roles => :nagios do
297
+ target_host = Capistrano::CLI.ui.ask "target hostname"
298
+ run "/usr/local/nagios/libexec/check_nrpe -H #{target_host}"
299
+ end
300
+
301
+ end
302
+
303
+
304
+ end
305
+ end