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,115 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :example do
5
+
6
+ SRC_PACKAGES[:example] = {
7
+ :filename => 'example-1.2.3.tar.gz',
8
+ :md5sum => "d050a49bd72222ec21c6bb593b3473a5d example-1.2.3.tar.gz",
9
+ :dir => 'example-1.2.3',
10
+ :url => "http://www.example.org/dist/example/example-1.2.3.tar.gz",
11
+ :unpack => "tar zxf example-1.2.3.tar.gz;",
12
+ :configure => %w(
13
+ ./configure
14
+ --enable-mods-shared=all
15
+ --enable-proxy
16
+ ;
17
+ ).reject{|arg| arg.match '#'}.join(' '),
18
+ :make => 'make;',
19
+ :install => 'make install;',
20
+ :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
21
+ }
22
+
23
+ desc "Install example"
24
+ task :install, :roles => :web do
25
+ install_deps
26
+ deprec2.download_src(SRC_PACKAGES[:example], src_dir)
27
+ deprec2.install_from_src(SRC_PACKAGES[:example], src_dir)
28
+ end
29
+
30
+ task :install_deps do
31
+ apt.install( {:base => %w(build-essential zlib1g-dev)}, :stable )
32
+ end
33
+
34
+ SYSTEM_CONFIG_FILES[:example] = [
35
+
36
+ {:template => "example.conf.erb",
37
+ :path => '/etc/example/example.conf',
38
+ :mode => 0755,
39
+ :owner => 'root:root'}
40
+
41
+ ]
42
+
43
+ PROJECT_CONFIG_FILES[:example] = [
44
+
45
+ {:template => "example.conf.erb",
46
+ :path => 'conf/example.conf',
47
+ :mode => 0755,
48
+ :owner => 'root:root'}
49
+ ]
50
+
51
+
52
+ desc "Generate configuration file(s) for XXX from template(s)"
53
+ task :config_gen do
54
+ config_gen_system
55
+ config_gen_project
56
+ end
57
+
58
+ task :config_gen_system do
59
+ SYSTEM_CONFIG_FILES[:example].each do |file|
60
+ deprec2.render_template(:example, file)
61
+ end
62
+ end
63
+
64
+ task :config_gen_project do
65
+ PROJECT_CONFIG_FILES[:example].each do |file|
66
+ deprec2.render_template(:example, file)
67
+ end
68
+ end
69
+
70
+ desc 'Deploy configuration files(s) for XXX'
71
+ task :config, :roles => :web do
72
+ config_system
73
+ config_project
74
+ end
75
+
76
+ task :config_system, :roles => :web do
77
+ deprec2.push_configs(:example, SYSTEM_CONFIG_FILES[:example])
78
+ end
79
+
80
+ task :config_project, :roles => :web do
81
+ deprec2.push_configs(:example, PROJECT_CONFIG_FILES[:example])
82
+ end
83
+
84
+
85
+ task :start, :roles => :web do
86
+ send(run_method, "/etc/init.d/example reload")
87
+ end
88
+
89
+ task :stop, :roles => :web do
90
+ send(run_method, "/etc/init.d/example reload")
91
+ end
92
+
93
+ task :restart, :roles => :web do
94
+ send(run_method, "/etc/init.d/example restart")
95
+ end
96
+
97
+ task :reload, :roles => :web do
98
+ send(run_method, "/etc/init.d/example reload")
99
+ end
100
+
101
+ task :activate, :roles => :web do
102
+ end
103
+
104
+ task :deactivate, :roles => :web do
105
+ end
106
+
107
+ task :backup, :roles => :web do
108
+ end
109
+
110
+ task :restore, :roles => :web do
111
+ end
112
+
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,97 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :git do
5
+
6
+ set :git_user, 'git'
7
+ set :git_group, 'git'
8
+ set :git_port, '9418'
9
+ set :git_keys_file, '/home/git/.ssh/authorized_keys'
10
+ set :git_root, '/var/git'
11
+
12
+ SRC_PACKAGES[:git] = {
13
+ :url => "http://kernel.org/pub/software/scm/git/git-1.6.1.tar.gz",
14
+ :md5sum => "1f915929d4f54a2e0449a4a08f093118 git-1.6.1.tar.gz"
15
+ }
16
+
17
+ desc "Install git"
18
+ task :install do
19
+ install_deps
20
+ deprec2.download_src(SRC_PACKAGES[:git], src_dir)
21
+ deprec2.install_from_src(SRC_PACKAGES[:git], src_dir)
22
+ # create_git_root
23
+ # create_git_user
24
+ end
25
+
26
+ # install dependencies for nginx
27
+ task :install_deps do
28
+ apt.install( {:base => %w(zlib1g-dev gettext libcurl4-gnutls-dev)}, :stable )
29
+ end
30
+
31
+ # "Start git server in local directory"
32
+ task :serve do
33
+ cmd = "git-daemon --verbose --port=#{git_port} --base-path=#{Dir.pwd} --base-path-relaxed"
34
+ puts cmd
35
+ `#{cmd}`
36
+ end
37
+
38
+ desc "Create git repos for current dir"
39
+ task :init do
40
+ `git init`
41
+ create_gitignore
42
+ create_files_in_empty_dirs
43
+ `git add . && git commit -m 'initial import'`
44
+ end
45
+
46
+ task :create_gitignore do
47
+ system("echo '.DS_Store' >> .gitignore") # files sometimes created by OSX
48
+ system("echo 'log/*' >> .gitignore") if File.directory?('log')
49
+ system("echo 'tmp/**/*' >> .gitignore") if File.directory?('tmp')
50
+ end
51
+
52
+ task :create_files_in_empty_dirs do
53
+ %w(log tmp).each { |dir|
54
+ system("touch #{dir}/.gitignore") if File.directory?(dir)
55
+ }
56
+ end
57
+
58
+ desc "Create remote origin for current dir"
59
+ task :create_remote_origin do
60
+ File.directory?('.git') || init
61
+
62
+ # Push to remote git repo
63
+ hostname = capture "echo $CAPISTRANO:HOST$"
64
+ system "git remote add origin git@#{hostname.chomp}:#{application}"
65
+ system "git push origin master:refs/heads/master"
66
+
67
+ puts
68
+ puts "New remote Git repo: #{git_user}@#{hostname.chomp}:#{application}"
69
+ puts
70
+
71
+ # File.open('.git/config', 'w') do |c|
72
+ # c.write 'Add the following to .git/config'
73
+ # c.write '[branch "master"]'
74
+ # c.write ' remote = origin'
75
+ # c.write ' merge = refs/heads/master'
76
+ # end
77
+
78
+ end
79
+
80
+ # Create root dir for git repositories
81
+ task :create_git_root do
82
+ deprec2.mkdir(git_root, :mode => 02775, :owner => git_user, :group => git_group, :via => :sudo)
83
+ sudo "chmod -R g+w #{git_root}"
84
+ end
85
+
86
+ # regenerate git authorized keys file from users file in same dir
87
+ task :regenerate_authorized_keys do
88
+ sudo "echo '' > #{git_keys_file}"
89
+ sudo "for file in `ls #{git_keys_file}-*`; do cat $file >> #{git_keys_file}; echo \"\n\" >> #{git_keys_file} ; done"
90
+ sudo "chown #{git_user}.#{git_group} #{git_keys_file}"
91
+ sudo "chmod 0600 #{git_keys_file}"
92
+ end
93
+
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,48 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :gitosis do
5
+
6
+ # ref: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
7
+
8
+ set :gitosis_user, 'git'
9
+
10
+ desc "Install git"
11
+ task :install do
12
+ deprec2.create_src_dir
13
+ install_deps
14
+ run <<-SUDO
15
+ cd #{src_dir} && test -d gitosis || #{sudo} git clone git://eagain.net/gitosis.git; exit 0
16
+ SUDO
17
+ run "cd #{src_dir}/gitosis && #{sudo} python setup.py install"
18
+ create_user
19
+ init
20
+ end
21
+
22
+ # install dependencies for nginx
23
+ task :install_deps do
24
+ apt.install( {:base => %w(python-setuptools)}, :stable )
25
+ end
26
+
27
+ # Create user for gitosis to run as
28
+ # This will also be the account you use for ssh access to git
29
+ task :create_user do
30
+ run "grep '^#{gitosis_user}:' /etc/passwd || #{sudo} adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/#{gitosis_user} #{gitosis_user}"
31
+ sudo "passwd --unlock #{gitosis_user}"
32
+ end
33
+
34
+ task :init do
35
+ sudo "sudo -H -u #{git_user} gitosis-init < ~/.ssh/authorized_keys"
36
+ sudo "chmod 0755 /home/git/repositories/gitosis-admin.git/hooks/post-update"
37
+ puts
38
+ puts "Now check out the gitosis-admin repos, edit configs and push changes back"
39
+ puts "Your changes with update gitosis as soon as they are checked in."
40
+ puts
41
+ puts "git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git"
42
+ puts "cd gitosis-admin"
43
+ puts ""
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,138 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :heartbeat do
5
+ set(:heartbeat_nodes) { find_servers_for_task(current_task) }
6
+ set(:heartbeat_preferred_node) {
7
+ Capistrano::CLI.ui.choose do |menu|
8
+ heartbeat_nodes.each {|c| menu.choice(c)}
9
+ menu.header = "select preferred node"
10
+ end
11
+ }
12
+ set(:heartbeat_resources) {Capistrano::CLI.ui.ask 'Enter resource to share. e.g. an ip address'}
13
+ set(:heartbeat_auth_key) { Capistrano::CLI.ui.ask 'Enter auth key for heartbeat to use' }
14
+ set(:heartbeat_ping) { Capistrano::CLI.ui.ask 'Enter IP address nodes will ping to test connectivity. e.g. gateway address' }
15
+ set(:heartbeat_bcast) {
16
+ Capistrano::CLI.ui.ask 'Enter ethernet interface(s) Heartbeat sends UDP broadcast traffic on. e.g. eth0' do |q|
17
+ q.default = 'eth0'
18
+ end
19
+ }
20
+ set(:heartbeat_auto_failback) {
21
+ Capistrano::CLI.ui.ask 'Should resource(s) automatically fail back to its "primary" node ' do |q|
22
+ q.default = 'yes'
23
+ end
24
+ }
25
+
26
+ desc "Install Heartbeat"
27
+ task :install do
28
+ install_deps
29
+ end
30
+
31
+ # Install dependencies for heartbeat
32
+ task :install_deps do
33
+ apt.install( {:base => %w(heartbeat-2)}, :stable )
34
+ end
35
+
36
+ SYSTEM_CONFIG_FILES[:heartbeat] = [
37
+
38
+ {:template => 'ha.cf.erb',
39
+ :path => '/etc/ha.d/ha.cf',
40
+ :mode => 0644,
41
+ :owner => 'root:root'},
42
+
43
+ {:template => 'haresources.erb',
44
+ :path => '/etc/ha.d/haresources',
45
+ :mode => 0644,
46
+ :owner => 'root:root'},
47
+
48
+ {:template => 'authkeys.erb',
49
+ :path => '/etc/ha.d/authkeys',
50
+ :mode => 0600,
51
+ :owner => 'root:root'}
52
+
53
+ ]
54
+
55
+ desc "Generate configuration file(s) for heartbeat from template(s)"
56
+ task :config_gen do
57
+ if ENV['ROLES']
58
+ SYSTEM_CONFIG_FILES[:heartbeat].each do |file|
59
+ file.merge!({:path => "#{file[:path]}-#{ENV['ROLES']}"})
60
+ deprec2.render_template(:heartbeat, file)
61
+ end
62
+ else
63
+ puts
64
+ puts "Whoops!"
65
+ puts
66
+ puts "You need to specify the cluster to work on by defining ROLES env variable."
67
+ puts "e.g. cap deprec:heartbeat:config ROLES=cluster_web"
68
+ puts
69
+ end
70
+ end
71
+
72
+ desc "Push heartbeat config files to server"
73
+ task :config do
74
+ if ENV['ROLES']
75
+ config_files = SYSTEM_CONFIG_FILES[:heartbeat].collect{|file| file.merge({:path => "#{file[:path]}-#{ENV['ROLES']}"})}
76
+ deprec2.push_configs(:heartbeat, config_files)
77
+ SYSTEM_CONFIG_FILES[:heartbeat].each {|file|
78
+ sudo "mv #{file[:path]}-#{ENV['ROLES']} #{file[:path]}"
79
+ }
80
+ # puts config_files
81
+ else
82
+ puts
83
+ puts "Whoops!"
84
+ puts
85
+ puts "You need to specify the cluster to work on by defining ROLES env variable."
86
+ puts "e.g. cap deprec:heartbeat:config ROLES=cluster_web"
87
+ puts
88
+ end
89
+ end
90
+
91
+ desc "Set Heartbeat to start on boot"
92
+ task :activate, :roles => :heartbeat do
93
+ send(run_method, "update-rc.d heartbeat defaults")
94
+ end
95
+
96
+ desc "Set Heartbeat to not start on boot"
97
+ task :deactivate, :roles => :heartbeat do
98
+ send(run_method, "update-rc.d -f heartbeat remove")
99
+ end
100
+
101
+
102
+ # Control
103
+
104
+ # XXX perhaps define a cluster to work with
105
+ # XXX e.g. set :cluster, 'rolename'
106
+ # XXX and then target that rolename with these tasks
107
+
108
+ desc "Start Heartbeat"
109
+ task :start, :roles => :heartbeat do
110
+ send(run_method, "/etc/init.d/heartbeat start")
111
+ end
112
+
113
+ desc "Stop Heartbeat"
114
+ task :stop, :roles => :heartbeat do
115
+ send(run_method, "/etc/init.d/heartbeat stop")
116
+ end
117
+
118
+ desc "Restart Heartbeat"
119
+ task :restart, :roles => :heartbeat do
120
+ send(run_method, "/etc/init.d/heartbeat restart")
121
+ end
122
+
123
+ desc "Reload Heartbeat"
124
+ task :reload, :roles => :heartbeat do
125
+ send(run_method, "/etc/init.d/heartbeat reload")
126
+ end
127
+
128
+ task :backup, :roles => :web do
129
+ # not yet implemented
130
+ end
131
+
132
+ task :restore, :roles => :web do
133
+ # not yet implemented
134
+ end
135
+
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :logrotate do
5
+
6
+ # Install
7
+
8
+ desc "Install logrotate"
9
+ task :install do
10
+ install_deps
11
+ SYSTEM_CONFIG_FILES[:logrotate].each do |file|
12
+ deprec2.render_template(:logrotate, file.merge(:remote => true))
13
+ end
14
+ end
15
+
16
+ # install dependencies for nginx
17
+ task :install_deps do
18
+ apt.install( {:base => %w(logrotate)}, :stable )
19
+ end
20
+
21
+ # Configure
22
+
23
+ SYSTEM_CONFIG_FILES[:logrotate] = [
24
+
25
+ {:template => 'logrotate.conf.erb',
26
+ :path => '/etc/logrotate.conf',
27
+ :mode => 0755,
28
+ :owner => 'root:root'}
29
+ ]
30
+
31
+ desc "Generate logrotate config from template."
32
+ task :config_gen do
33
+ SYSTEM_CONFIG_FILES[:logrotate].each do |file|
34
+ deprec2.render_template(:logrotate, file)
35
+ end
36
+ end
37
+
38
+ desc "Push logrotate config files to server"
39
+ task :config do
40
+ deprec2.push_configs(:logrotate, SYSTEM_CONFIG_FILES[:logrotate])
41
+ end
42
+
43
+ # Control
44
+ #
45
+ # logrotate is run via cron with a script in /etc/cron.daily/logrotate
46
+
47
+ desc "Force logrotate to run"
48
+ task :force do
49
+ sudo "logrotate -f /etc/logrotate.conf"
50
+ end
51
+
52
+ end
53
+ end
54
+ end