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,101 @@
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 :xentools do
5
+
6
+ SRC_PACKAGES[:xentools] = {
7
+ :url => "http://www.xen-tools.org/software/xen-tools/xen-tools-4.1.tar.gz",
8
+ :md5sum => "156ec5991f3885ef0daa58c3424d0a35 xen-tools-4.1.tar.gz",
9
+ :configure => '',
10
+ :make => ''
11
+ }
12
+
13
+ desc "Install xen-tools"
14
+ task :install, :roles => :dom0 do
15
+ install_deps
16
+ deprec2.download_src(SRC_PACKAGES[:xentools], src_dir)
17
+ deprec2.install_from_src(SRC_PACKAGES[:xentools], src_dir)
18
+ initial_config
19
+ end
20
+
21
+ task :install_deps, :roles => :dom0 do
22
+ # Cheeky way to ensure we have the dependencies - Mike
23
+ apt.install( {:base => %w(xen-tools libexpect-perl)}, :stable )
24
+ end
25
+
26
+ SYSTEM_CONFIG_FILES[:xentools] = [
27
+
28
+ {:template => "xen-tools.conf.erb",
29
+ :path => '/etc/xen-tools/xen-tools.conf',
30
+ :mode => 0644,
31
+ :owner => 'root:root'},
32
+
33
+ {:template => "xm.tmpl.erb",
34
+ :path => '/etc/xen-tools/xm.tmpl',
35
+ :mode => 0644,
36
+ :owner => 'root:root'},
37
+
38
+ # This one is a bugfix for gutsy
39
+ {:template => "15-disable-hwclock",
40
+ :path => '/usr/lib/xen-tools/gutsy.d/15-disable-hwclock',
41
+ :mode => 0755,
42
+ :owner => 'root:root'},
43
+
44
+ # This one is a bugfix for gutsy: domU -> domU networking is screwy
45
+ # http://lists.xensource.com/archives/html/xen-users/2006-05/msg00818.html
46
+ {:template => "40-setup-networking",
47
+ :path => '/usr/lib/xen-tools/gutsy.d/40-setup-networking',
48
+ :mode => 0755,
49
+ :owner => 'root:root'},
50
+
51
+ # bugfix: #/bin/sh -> #!/bin/sh
52
+ # bugfix: $i => $1
53
+ {:template => "100-ubuntu-setup",
54
+ :path => '/usr/lib/xen-tools/gutsy.d/100-ubuntu-setup',
55
+ :mode => 0755,
56
+ :owner => 'root:root'},
57
+
58
+ # bugfix: make sure serial device is created and correct file is edited (/etc/inittab is not used anymore!)
59
+ {:template => "30-disable-gettys",
60
+ :path => '/usr/lib/xen-tools/gutsy.d/30-disable-gettys',
61
+ :mode => 0755,
62
+ :owner => 'root:root'},
63
+
64
+ # bugfix: removed serial device code, since that's already performed in 30-disable-gettys
65
+ # bugfix: #/bin/sh -> #!/bin/sh
66
+ {:template => "31-ubuntu-setup",
67
+ :path => '/usr/lib/xen-tools/gutsy.d/31-ubuntu-setup',
68
+ :mode => 0755,
69
+ :owner => 'root:root'},
70
+
71
+ # added script for user adjustments to debootstrap results
72
+ # modify this file inside your project (i.e. not in deprec itself) to added your own xen-tools steps
73
+ {:template => "98-custom",
74
+ :path => '/usr/lib/xen-tools/gutsy.d/98-custom',
75
+ :mode => 0755,
76
+ :owner => 'root:root'}
77
+ ]
78
+
79
+ task :initial_config, :roles => :dom0 do
80
+ # Non-standard! We're pushing these straight out
81
+ SYSTEM_CONFIG_FILES[:xentools].each do |file|
82
+ deprec2.render_template(:xentools, file.merge(:remote => true))
83
+ end
84
+ end
85
+
86
+ desc "Generate configuration file(s) for xen-tools from template(s)"
87
+ task :config_gen do
88
+ SYSTEM_CONFIG_FILES[:xentools].each do |file|
89
+ deprec2.render_template(:xentools, file)
90
+ end
91
+ end
92
+
93
+ desc "Push xen-tools config files to server"
94
+ task :config, :roles => :dom0 do
95
+ deprec2.push_configs(:xentools, SYSTEM_CONFIG_FILES[:xentools])
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,125 @@
1
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
2
+ unless Capistrano::Configuration.respond_to?(:instance)
3
+ abort "deprec2 requires Capistrano 2"
4
+ end
5
+
6
+ # manually loading all recipes is cumbersome and leads to a lot of conflicts when merging branches.
7
+ # I rewrote this file so recipes get loaded automatically. Only files mentioned in the dependencies list and all
8
+ # files ending in .rb get loaded, so rename them to prevent them being loaded (as I did with some based on the
9
+ # old code)
10
+
11
+ # Loading is done as follows:
12
+ # - define a dependencies list
13
+ # - from that list, derive a load order
14
+ # - load the rest of the recipes to the end of the load order list
15
+ # - require all recipes mentioned in the load order list in the order that they are mentioned
16
+
17
+ def load_recipe_names(base_dir, prefix = '')
18
+ recipes = []
19
+ Dir.new(base_dir).entries.each do |entry|
20
+ next if [ ".", "..", "rails" ].include?(entry)
21
+ fqn = File.join(base_dir, entry)
22
+ if File.directory?(fqn)
23
+ recipes += load_recipe_names(fqn, "#{prefix}#{entry}/")
24
+ elsif fqn =~ /\.rb$/
25
+ recipes << "#{prefix}#{entry.gsub(/\.rb$/, '')}"
26
+ end
27
+ end
28
+ recipes
29
+ end
30
+
31
+ def order_dependencies(&block)
32
+ copy_of_dependencies = {}
33
+ # load defined dependencies + make values of type array if they aren't + add entries for non-mentioned dependencies
34
+ # themselves
35
+ yield().each do |recipe, dependencies|
36
+ copy_of_dependencies[recipe.to_s] = [dependencies].flatten.collect { |dependency| dependency.to_s }
37
+ copy_of_dependencies[recipe.to_s].each do |dependency|
38
+ copy_of_dependencies[dependency] = [] if copy_of_dependencies[dependency].nil?
39
+ end
40
+ end
41
+ recipies_load_order = []
42
+
43
+ # define load order for all depended upon recipes
44
+ offset = 0
45
+ while copy_of_dependencies.keys.size > 0 do
46
+ current = copy_of_dependencies.keys[offset]
47
+ if current.nil? && offset > 0
48
+ offset -= 1
49
+ next
50
+ end
51
+ raise "cannot find recipe #{current}.rb in the filesystem!" if !File.exist?("#{File.dirname(__FILE__)}/recipes/#{current}.rb")
52
+ dependencies = copy_of_dependencies[current]
53
+ if dependencies.size == 0 || dependencies.all? { |dependency| recipies_load_order.include?(dependency) }
54
+ recipies_load_order << current
55
+ copy_of_dependencies.delete(current)
56
+ else
57
+ offset = (offset + 1) % copy_of_dependencies.keys.size
58
+ end
59
+ end
60
+
61
+ load_recipe_names("#{File.dirname(__FILE__)}/recipes/").each do |recipe|
62
+ recipies_load_order << recipe unless recipies_load_order.include?(recipe)
63
+ end
64
+
65
+ recipies_load_order
66
+ end
67
+
68
+ recipies_load_order = order_dependencies do
69
+ # key is the recipe to load, value is the recipe that should be loaded earlier already
70
+ # value can be an array (to denote multiple dependencies), but doesn't have to be
71
+ # TODO: cleanup and minimize number of dependencies.
72
+ # NOTE: this is only needed to define a load order. If one recipe is needed to be loaded
73
+ # before all others, just mention it by itself with an empty array dependencies list, since
74
+ # all other recipes are loaded after the recipes mentioned here.
75
+ # NOTE2: internally the dependencies processor works with strings, but we can specify using
76
+ # symbols here
77
+ {
78
+ :deprec => :canonical,
79
+ :deprecated => :deprec,
80
+ :chef => :deprecated,
81
+ :"app/mongrel" => :chef,
82
+ :"app/passenger" => :"app/mongrel",
83
+ :"db/mysql" => :"app/passenger",
84
+ :"db/postgresql" => :"db/mysql",
85
+ :"db/sqlite" => :"db/postgresql",
86
+ :"db/couchdb" => :"db/sqlite",
87
+ :"ruby/mri" => :"db/couchdb",
88
+ :"ruby/ree" => :"ruby/mri",
89
+ :"web/apache" => :"ruby/ree",
90
+ :"web/nginx" => :"web/apache",
91
+ :git => :"web/nginx",
92
+ :svn => :git,
93
+ :integrity => :svn,
94
+ :users => :integrity,
95
+ :ssh => :users,
96
+ :php => :ssh,
97
+ :aoe => :php,
98
+ :xen => :aoe,
99
+ :xentools => :xen,
100
+ :ddclient => :xentools,
101
+ :ntp => :ddclient,
102
+ :logrotate => :ntp,
103
+ :ssl => :logrotate,
104
+ :postfix => :ssl,
105
+ :memcache => :postfix,
106
+ :monit => :memcache,
107
+ :network => :monit,
108
+ :nagios => :network,
109
+ :collectd => :nagios,
110
+ :syslog => :collectd,
111
+ :heartbeat => :syslog,
112
+ :haproxy => :heartbeat,
113
+ :ubuntu => :haproxy,
114
+ :lvm => :ubuntu,
115
+ :vnstat => :lvm,
116
+ :utils => :vnstat,
117
+ :wpmu => :utils,
118
+ :ar_sendmail => :wpmu,
119
+ :starling => :ar_sendmail
120
+ }
121
+ end
122
+
123
+ recipies_load_order.each do |recipe|
124
+ require "#{File.dirname(__FILE__)}/recipes/#{recipe}"
125
+ end
@@ -0,0 +1,55 @@
1
+ #! /bin/sh
2
+ # aoe-init - example init script for ATA over Ethernet storage
3
+ #
4
+ # Edit this script for your purposes. (Changing "eth1" to the
5
+ # appropriate interface name, adding commands, etc.) You might
6
+ # need to tune the sleep times.
7
+ #
8
+ # Install this script in /etc/init.d with the other init scripts.
9
+ #
10
+ # Make it executable:
11
+ # chmod 755 /etc/init.d/aoe-init
12
+ #
13
+ # Install symlinks for boot time:
14
+ # cd /etc/rc3.d && ln -s ../init.d/aoe-init S99aoe-init
15
+ # cd /etc/rc5.d && ln -s ../init.d/aoe-init S99aoe-init
16
+ #
17
+ # Install symlinks for shutdown time:
18
+ # cd /etc/rc0.d && ln -s ../init.d/aoe-init K01aoe-init
19
+ # cd /etc/rc1.d && ln -s ../init.d/aoe-init K01aoe-init
20
+ # cd /etc/rc2.d && ln -s ../init.d/aoe-init K01aoe-init
21
+ # cd /etc/rc6.d && ln -s ../init.d/aoe-init K01aoe-init
22
+ #
23
+
24
+ case "$1" in
25
+ "start")
26
+ # load any needed network drivers here
27
+
28
+ # replace "eth1" with your aoe network interface
29
+ ifconfig eth1 up
30
+
31
+ # time for network interface to come up
32
+ sleep 4
33
+
34
+ modprobe aoe
35
+
36
+ # time for AoE discovery and udev
37
+ sleep 7
38
+
39
+ # add your raid assemble commands here
40
+ # add any LVM commands if needed (e.g. vgchange)
41
+ # add your filesystem mount commands here
42
+
43
+ test -d /var/lock/subsys && touch /var/lock/subsys/aoe-init
44
+ ;;
45
+ "stop")
46
+ # add your filesystem umount commands here
47
+ # deactivate LVM volume groups if needed
48
+ # add your raid stop commands here
49
+ rmmod aoe
50
+ rm -f /var/lock/subsys/aoe-init
51
+ ;;
52
+ *)
53
+ echo "usage: `basename $0` {start|stop}" 1>&2
54
+ ;;
55
+ esac
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/perl
2
+
3
+ #
4
+ # Wrapper to aoemask for use in a cluster fence.
5
+ # Copyright (C) 2007 Brian Weck (bweck@weck.net)
6
+ #
7
+ # This script utilizes the 'aoemask' utility from:
8
+ # http://www.coraid.com/support/sr/
9
+ # which is written by Sam Hopkins.
10
+ #
11
+ # =======================================================================
12
+ # This program is free software; you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation; either version 2 of the License, or
15
+ # (at your option) any later version.
16
+ #
17
+ # This program is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ # GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License
23
+ # along with this program; if not, write to the Free Software
24
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
+ # =======================================================================
26
+ #
27
+ # ~~~~~ REVISION HISTORY ~~~~~
28
+ # 2007-08-17 - v1 - Brian Weck
29
+ # Initial release.
30
+ #
31
+ # ~~~~~ OVERVIEW ~~~~~
32
+ # Initial mask settings on the AoE device should contain the set of all
33
+ # MAC addresses using the AoE device from the cluster.
34
+ #
35
+ # When a fence operation occurs on a node, the fenced node's mac address is
36
+ # removed from the mask list on the AoE device. This method is conceptually
37
+ # the same as fencing via a fabric switch.
38
+ #
39
+ # Once a node is fenced, the MAC address is removed from the mask list on
40
+ # the AoE device. When the fenced node is ready to rejoin the cluster,
41
+ # the MAC address must be added to the device's mask list using this
42
+ # script or using aoemask.
43
+ #
44
+ # Script returns 0 on SUCCESS and non-zero otherwise.
45
+ #
46
+ # ~~~~~ INSTALLATION ~~~~~
47
+ # Add this file as /sbin/fence_aoemask directory and ensure the file has
48
+ # simliar permissions as the other fence_* agents.
49
+ #
50
+ # ~~~~~ CONFIGURATION ~~~~~
51
+ # This software operates on a single shelf / slot at a time. In order to
52
+ # fence multiple shelf and slots the user should create multiple fences.
53
+ #
54
+ # e.g. a cluster.conf snippet.
55
+ # <clusternode name="node1-name" nodeid="1" votes="1">
56
+ # <fence>
57
+ # <method name="1">
58
+ # <device name="fence-e0.0" mac="56:f7:0c:da:e2:2f" />
59
+ # <device name="fence-e0.1" mac="56:f7:0c:da:e2:2f" />
60
+ # </method>
61
+ # </fence>
62
+ # </clusternode>
63
+ # <clusternode name="node2-name" nodeid="2" votes="1">
64
+ # <fence>
65
+ # <method name="1">
66
+ # <device name="fence-e0.0" mac="ec:fc:96:3b:69:5a" />
67
+ # <device name="fence-e0.1" mac="ec:fc:96:3b:69:5a" />
68
+ # </method>
69
+ # </fence>
70
+ # </clusternode>
71
+ # <fencedevices>
72
+ # <fencedevice agent="fence_aoemask" name="fence-e0.0" shelf="0" slot="0" interface="eth1"/>
73
+ # <fencedevice agent="fence_aoemask" name="fence-e0.1" shelf="0" slot="1" interface="eth1"/>
74
+ # </fencedevices>
75
+ #
76
+ #
77
+ # Command line options:
78
+ # see man aoemask.8
79
+ #
80
+ # stdin options (passed from fenced):
81
+ # shelf=<num> |
82
+ # slot=<num> |
83
+ # interface=<if-name> |
84
+ # mac=<mac-addr> |
85
+ # [ action=(disable|enable) ] | default is defined in $opt_action
86
+ # [ debug=<ignored-value> ] |
87
+ # [ exclusive=<ignored-value> ] |
88
+ # [ list=<ignored-value> ] |
89
+ # [ spoof=<mac-addr> ] | Spoof behavior is to assume success always.
90
+ # [ timeout=<wait-seconds> ] |
91
+ # [ verbose=<ignored-value> ] | Option is used to increase logging of fence agent.
92
+ #
93
+
94
+ # Define where you aoemask binary lives if it is not in the path.
95
+ my $aoemask_prog="/usr/local/sbin/aoemask";
96
+ my $opt_action = 'disable'; # Default fence action
97
+
98
+ # Get the script name from $0 and strip directory names
99
+ $_=$0;
100
+ s/.*\///;
101
+ my $proggy = $_;
102
+
103
+ #
104
+ #
105
+ #
106
+ my $aoemask=$aoemask_prog;
107
+ my $opt_list = 1;
108
+ my $opt_debug = 1;
109
+ my $opt_verbose = 0;
110
+
111
+ #
112
+ sub _log
113
+ {
114
+ ($msg)=@_;
115
+ print STDOUT $msg;
116
+ }
117
+
118
+ #
119
+ sub exit_success
120
+ {
121
+ my $rc = 0;
122
+ _log "$proggy returning $rc\n" if $opt_verbose;
123
+ exit $rc;
124
+ }
125
+
126
+ #
127
+ sub exit_fail
128
+ {
129
+ my $rc = 1;
130
+ _log "$proggy returning $rc\n" if $opt_verbose;
131
+ exit $rc;
132
+ }
133
+
134
+ #
135
+ sub fail_usage
136
+ {
137
+ ($msg)=@_;
138
+ _log $msg."\n" if $msg;
139
+ _log "Please use see usage.\n";
140
+ exit_fail();
141
+ }
142
+
143
+ #
144
+ # If running command line, pass args as specified directly to aoemask
145
+ if (@ARGV > 0)
146
+ {
147
+ # Check for min number of args, 5
148
+ if( @ARGV < 5 )
149
+ {
150
+ $aoemask .= " -h";
151
+ }
152
+ else
153
+ {
154
+ # stub in the args
155
+ foreach $i (0 .. $#ARGV)
156
+ {
157
+ $aoemask .= " $ARGV[$i]";
158
+ }
159
+ }
160
+ }
161
+ else # Running via fenced, read the args in from stdin
162
+ {
163
+ read_stdin_as_options();
164
+
165
+ # validate required args are present
166
+ fail_usage "No shelf specified." unless defined $opt_shelf;
167
+ fail_usage "No slot specified." unless defined $opt_slot;
168
+ fail_usage "No interface specified." unless defined $opt_interface;
169
+ fail_usage "No mac specified." unless defined $opt_mac;
170
+
171
+ $aoemask .= " -d" if defined $opt_debug;
172
+ $aoemask .= " -e" if defined $opt_exclusive;
173
+ $aoemask .= " -l" if defined $opt_list;
174
+ $aoemask .= " -s $opt_spoof" if defined $opt_spoof;
175
+ $aoemask .= " -w $opt_timeout" if defined $opt_timeout;
176
+ $aoemask .= " $opt_shelf $opt_slot $opt_interface";
177
+
178
+ $_=$opt_action;
179
+ if (/enable/) { $aoemask .= " +$opt_mac"; }
180
+ elsif (/disable/) { $aoemask .= " -$opt_mac"; }
181
+ else
182
+ {
183
+ # This would only be reached if in the cluster.conf one specified action=
184
+ fail_usage "Unknown action: $_";
185
+ }
186
+ }
187
+
188
+ _log "$proggy executing '$aoemask'\n" if $opt_verbose;
189
+
190
+ #
191
+ # aoemask (release 1) always returns an exit code of 1
192
+ # if aoemask returned success or failure based on the response; could as follows:
193
+ #
194
+ # system($aoemask);
195
+ # $rc = ($? >> 8) & 0xff;
196
+ # exit $rc;
197
+ #
198
+
199
+ # therefore, we must ensure the listing function is performed and grep'd
200
+ open(FH, "$aoemask 2>&1 |");
201
+ @lines = <FH>;
202
+ close FH;
203
+
204
+ #
205
+ if ($opt_verbose)
206
+ {
207
+ _log "-- begin read response --\n";
208
+ foreach $line (@lines) { chop $line; _log "$line\n"; }
209
+ _log "-- end read response --\n";
210
+ }
211
+
212
+ #
213
+ if ($opt_user_says_list)
214
+ {
215
+ @x = grep { /$opt_shelf\.$opt_slot/ } @lines;
216
+ _log foreach @x;
217
+ }
218
+
219
+ #
220
+ # If spoofing, nothing is returned, we assume success.
221
+ exit_success() if $opt_spoof;
222
+
223
+ # check output of aoemask for proper values depending on action.
224
+ if( ($opt_action =~ /enable/) && (grep { /$opt_mac/ } @lines) )
225
+ {
226
+ _log "action is to enable and found mac $opt_mac in list"."\n" if $opt_verbose;
227
+ exit_success();
228
+ }
229
+ elsif( ($opt_action =~ /disable/) && !(grep { /$opt_mac/ } @lines) )
230
+ {
231
+ # here's a caveat .. which requires the debug flag to be on.
232
+ # if one is performing a disable, and specify an invalid slot / shelf / interface
233
+ # a grep for the mac will not show and therfore a return success.
234
+ #
235
+ # Workaround: need to check for an additional string, of:
236
+ # read -1 bytes
237
+ #
238
+ if( ! grep { /read -1 bytes/} @lines )
239
+ {
240
+ # did not read that string; all is ok.
241
+ _log "action is to disable and did not find mac $opt_mac in list"."\n" if $opt_verbose;
242
+ exit_success();
243
+ }
244
+ else
245
+ {
246
+ _log "No bytes were read from '$aoemask'.\n";
247
+ _log "Check the slot|shelf|interface configs.\n"
248
+ }
249
+ }
250
+
251
+ # If none of the above matched, we failed.
252
+ exit_fail();
253
+
254
+
255
+ #
256
+ # Parse the stdin options
257
+ #
258
+ sub read_stdin_as_options()
259
+ {
260
+ my $opt;
261
+ my $line = 0;
262
+ while( defined($in = <>) )
263
+ {
264
+ $_ = $in;
265
+ chomp;
266
+
267
+ # strip leading and trailing whitespace
268
+ s/^\s*//;
269
+ s/\s*$//;
270
+
271
+ # skip any comments
272
+ next if /^#/;
273
+
274
+ $line+=1;
275
+ $opt=$_;
276
+ next unless $opt;
277
+
278
+ ($name,$val)=split /\s*=\s*/, $opt;
279
+
280
+ if ( $name eq "" )
281
+ {
282
+ _log "parse error: illegal name in option $line\n";
283
+ exit_fail();
284
+ }
285
+
286
+ # shelf=<num>
287
+ # slot=<num>
288
+ # interface=<if-name>
289
+ # mac=<mac-addr>
290
+ # action=(disable|enable)
291
+ elsif ($name eq "shelf" )
292
+ {
293
+ $opt_shelf = $val;
294
+ }
295
+ elsif ($name eq "slot" )
296
+ {
297
+ $opt_slot = $val;
298
+ }
299
+ elsif ($name eq "interface" )
300
+ {
301
+ $opt_interface = $val;
302
+ }
303
+ elsif ($name eq "mac" )
304
+ {
305
+ $opt_mac = $val;
306
+ # pull out any ':' if configured as such.
307
+ # (even though aoemask can handle it)
308
+ $opt_mac =~ s/://g;
309
+ # uppercase the alphas
310
+ $opt_mac =~ tr/a-z/A-Z/;
311
+ }
312
+ elsif ($name eq "action")
313
+ {
314
+ $opt_action = $val;
315
+ }
316
+
317
+ # debug=<ignored-value>
318
+ # exclusive=<ignored-value>
319
+ # list=<ignored-value>
320
+ # spoof=<mac-addr>
321
+ # timeout=<wait-seconds>
322
+ elsif ($name eq "debug" )
323
+ {
324
+ $opt_debug = 1;
325
+ }
326
+ elsif ($name eq "exclusive" )
327
+ {
328
+ $opt_exclusive = 1;
329
+ }
330
+ elsif ($name eq "list" )
331
+ {
332
+ $opt_list = 1;
333
+ $opt_user_says_list = 1;
334
+ }
335
+ elsif ($name eq "spoof" )
336
+ {
337
+ $opt_spoof = $val;
338
+ }
339
+ elsif ($name eq "timeout" )
340
+ {
341
+ $opt_timeout = $val;
342
+ }
343
+
344
+ # verbose=<ignored-value>
345
+ elsif ($name eq "verbose" )
346
+ {
347
+ $opt_verbose = 1;
348
+ }
349
+ }
350
+ }
351
+