fast_food 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +73 -0
  5. data/Rakefile +8 -0
  6. data/chef/.chef/bootstrap/chef-solo.erb +27 -0
  7. data/chef/.chef/knife.rb +8 -0
  8. data/chef/.gitignore +1 -0
  9. data/chef/README +3 -0
  10. data/chef/cookbooks/README +1 -0
  11. data/chef/cookbooks/apache2/.gitignore +1 -0
  12. data/chef/cookbooks/apache2/CHANGELOG.md +81 -0
  13. data/chef/cookbooks/apache2/CONTRIBUTING +29 -0
  14. data/chef/cookbooks/apache2/Gemfile +10 -0
  15. data/chef/cookbooks/apache2/LICENSE +201 -0
  16. data/chef/cookbooks/apache2/README.md +373 -0
  17. data/chef/cookbooks/apache2/attributes/default.rb +149 -0
  18. data/chef/cookbooks/apache2/attributes/mod_auth_openid.rb +32 -0
  19. data/chef/cookbooks/apache2/definitions/apache_conf.rb +26 -0
  20. data/chef/cookbooks/apache2/definitions/apache_module.rb +53 -0
  21. data/chef/cookbooks/apache2/definitions/apache_site.rb +43 -0
  22. data/chef/cookbooks/apache2/definitions/web_app.rb +49 -0
  23. data/chef/cookbooks/apache2/files/default/apache2_module_conf_generate.pl +41 -0
  24. data/chef/cookbooks/apache2/files/default/tests/minitest/default_test.rb +64 -0
  25. data/chef/cookbooks/apache2/files/default/tests/minitest/helpers.rb +36 -0
  26. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_auth_openid_test.rb +25 -0
  27. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_dav_svn_test.rb +16 -0
  28. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_perl_test.rb +22 -0
  29. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_php5_test.rb +19 -0
  30. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_python_test.rb +14 -0
  31. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_ssl_test.rb +19 -0
  32. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_wsgi_test.rb +14 -0
  33. data/chef/cookbooks/apache2/files/default/tests/minitest/mod_xsendfile_test.rb +14 -0
  34. data/chef/cookbooks/apache2/files/default/tests/minitest/modules_test.rb +19 -0
  35. data/chef/cookbooks/apache2/metadata.json +511 -0
  36. data/chef/cookbooks/apache2/metadata.rb +205 -0
  37. data/chef/cookbooks/apache2/recipes/default.rb +221 -0
  38. data/chef/cookbooks/apache2/recipes/god_monitor.rb +33 -0
  39. data/chef/cookbooks/apache2/recipes/mod_alias.rb +22 -0
  40. data/chef/cookbooks/apache2/recipes/mod_apreq2.rb +45 -0
  41. data/chef/cookbooks/apache2/recipes/mod_auth_basic.rb +20 -0
  42. data/chef/cookbooks/apache2/recipes/mod_auth_digest.rb +20 -0
  43. data/chef/cookbooks/apache2/recipes/mod_auth_openid.rb +113 -0
  44. data/chef/cookbooks/apache2/recipes/mod_authn_file.rb +20 -0
  45. data/chef/cookbooks/apache2/recipes/mod_authnz_ldap.rb +20 -0
  46. data/chef/cookbooks/apache2/recipes/mod_authz_default.rb +20 -0
  47. data/chef/cookbooks/apache2/recipes/mod_authz_groupfile.rb +20 -0
  48. data/chef/cookbooks/apache2/recipes/mod_authz_host.rb +20 -0
  49. data/chef/cookbooks/apache2/recipes/mod_authz_user.rb +20 -0
  50. data/chef/cookbooks/apache2/recipes/mod_autoindex.rb +22 -0
  51. data/chef/cookbooks/apache2/recipes/mod_cgi.rb +20 -0
  52. data/chef/cookbooks/apache2/recipes/mod_dav.rb +20 -0
  53. data/chef/cookbooks/apache2/recipes/mod_dav_fs.rb +20 -0
  54. data/chef/cookbooks/apache2/recipes/mod_dav_svn.rb +29 -0
  55. data/chef/cookbooks/apache2/recipes/mod_deflate.rb +22 -0
  56. data/chef/cookbooks/apache2/recipes/mod_dir.rb +22 -0
  57. data/chef/cookbooks/apache2/recipes/mod_env.rb +20 -0
  58. data/chef/cookbooks/apache2/recipes/mod_expires.rb +20 -0
  59. data/chef/cookbooks/apache2/recipes/mod_fastcgi.rb +26 -0
  60. data/chef/cookbooks/apache2/recipes/mod_fcgid.rb +53 -0
  61. data/chef/cookbooks/apache2/recipes/mod_headers.rb +20 -0
  62. data/chef/cookbooks/apache2/recipes/mod_ldap.rb +20 -0
  63. data/chef/cookbooks/apache2/recipes/mod_log_config.rb +24 -0
  64. data/chef/cookbooks/apache2/recipes/mod_logio.rb +24 -0
  65. data/chef/cookbooks/apache2/recipes/mod_mime.rb +22 -0
  66. data/chef/cookbooks/apache2/recipes/mod_negotiation.rb +22 -0
  67. data/chef/cookbooks/apache2/recipes/mod_perl.rb +39 -0
  68. data/chef/cookbooks/apache2/recipes/mod_php5.rb +99 -0
  69. data/chef/cookbooks/apache2/recipes/mod_proxy.rb +22 -0
  70. data/chef/cookbooks/apache2/recipes/mod_proxy_ajp.rb +21 -0
  71. data/chef/cookbooks/apache2/recipes/mod_proxy_balancer.rb +20 -0
  72. data/chef/cookbooks/apache2/recipes/mod_proxy_connect.rb +20 -0
  73. data/chef/cookbooks/apache2/recipes/mod_proxy_http.rb +20 -0
  74. data/chef/cookbooks/apache2/recipes/mod_python.rb +32 -0
  75. data/chef/cookbooks/apache2/recipes/mod_rewrite.rb +20 -0
  76. data/chef/cookbooks/apache2/recipes/mod_setenvif.rb +22 -0
  77. data/chef/cookbooks/apache2/recipes/mod_ssl.rb +43 -0
  78. data/chef/cookbooks/apache2/recipes/mod_status.rb +22 -0
  79. data/chef/cookbooks/apache2/recipes/mod_wsgi.rb +27 -0
  80. data/chef/cookbooks/apache2/recipes/mod_xsendfile.rb +27 -0
  81. data/chef/cookbooks/apache2/templates/default/a2dismod.erb +22 -0
  82. data/chef/cookbooks/apache2/templates/default/a2dissite.erb +29 -0
  83. data/chef/cookbooks/apache2/templates/default/a2enmod.erb +37 -0
  84. data/chef/cookbooks/apache2/templates/default/a2ensite.erb +38 -0
  85. data/chef/cookbooks/apache2/templates/default/apache2.conf.erb +237 -0
  86. data/chef/cookbooks/apache2/templates/default/apache2.god.erb +19 -0
  87. data/chef/cookbooks/apache2/templates/default/charset.erb +6 -0
  88. data/chef/cookbooks/apache2/templates/default/default-site.erb +57 -0
  89. data/chef/cookbooks/apache2/templates/default/mods/README +2 -0
  90. data/chef/cookbooks/apache2/templates/default/mods/alias.conf.erb +24 -0
  91. data/chef/cookbooks/apache2/templates/default/mods/authopenid.load.erb +1 -0
  92. data/chef/cookbooks/apache2/templates/default/mods/autoindex.conf.erb +101 -0
  93. data/chef/cookbooks/apache2/templates/default/mods/deflate.conf.erb +16 -0
  94. data/chef/cookbooks/apache2/templates/default/mods/dir.conf.erb +5 -0
  95. data/chef/cookbooks/apache2/templates/default/mods/fastcgi.conf.erb +5 -0
  96. data/chef/cookbooks/apache2/templates/default/mods/fcgid.conf.erb +10 -0
  97. data/chef/cookbooks/apache2/templates/default/mods/mime.conf.erb +198 -0
  98. data/chef/cookbooks/apache2/templates/default/mods/negotiation.conf.erb +18 -0
  99. data/chef/cookbooks/apache2/templates/default/mods/php5.conf.erb +16 -0
  100. data/chef/cookbooks/apache2/templates/default/mods/proxy.conf.erb +19 -0
  101. data/chef/cookbooks/apache2/templates/default/mods/setenvif.conf.erb +28 -0
  102. data/chef/cookbooks/apache2/templates/default/mods/ssl.conf.erb +76 -0
  103. data/chef/cookbooks/apache2/templates/default/mods/status.conf.erb +26 -0
  104. data/chef/cookbooks/apache2/templates/default/port_apache.erb +2 -0
  105. data/chef/cookbooks/apache2/templates/default/ports.conf.erb +6 -0
  106. data/chef/cookbooks/apache2/templates/default/security.erb +50 -0
  107. data/chef/cookbooks/apache2/templates/default/web_app.conf.erb +43 -0
  108. data/chef/cookbooks/build-essential/.gitignore +4 -0
  109. data/chef/cookbooks/build-essential/CHANGELOG.md +31 -0
  110. data/chef/cookbooks/build-essential/CONTRIBUTING +29 -0
  111. data/chef/cookbooks/build-essential/Gemfile +3 -0
  112. data/chef/cookbooks/build-essential/LICENSE +201 -0
  113. data/chef/cookbooks/build-essential/README.md +129 -0
  114. data/chef/cookbooks/build-essential/attributes/default.rb +33 -0
  115. data/chef/cookbooks/build-essential/metadata.json +41 -0
  116. data/chef/cookbooks/build-essential/metadata.rb +14 -0
  117. data/chef/cookbooks/build-essential/recipes/default.rb +92 -0
  118. data/chef/cookbooks/database/.gitignore +1 -0
  119. data/chef/cookbooks/database/CHANGELOG.md +46 -0
  120. data/chef/cookbooks/database/CONTRIBUTING +29 -0
  121. data/chef/cookbooks/database/LICENSE +201 -0
  122. data/chef/cookbooks/database/README.md +468 -0
  123. data/chef/cookbooks/database/libraries/provider_database_mysql.rb +103 -0
  124. data/chef/cookbooks/database/libraries/provider_database_mysql_user.rb +76 -0
  125. data/chef/cookbooks/database/libraries/provider_database_postgresql.rb +131 -0
  126. data/chef/cookbooks/database/libraries/provider_database_postgresql_user.rb +83 -0
  127. data/chef/cookbooks/database/libraries/provider_database_sql_server.rb +109 -0
  128. data/chef/cookbooks/database/libraries/provider_database_sql_server_user.rb +106 -0
  129. data/chef/cookbooks/database/libraries/resource_database.rb +119 -0
  130. data/chef/cookbooks/database/libraries/resource_database_user.rb +90 -0
  131. data/chef/cookbooks/database/libraries/resource_mysql_database.rb +34 -0
  132. data/chef/cookbooks/database/libraries/resource_mysql_database_user.rb +34 -0
  133. data/chef/cookbooks/database/libraries/resource_postgresql_database.rb +35 -0
  134. data/chef/cookbooks/database/libraries/resource_postgresql_database_user.rb +35 -0
  135. data/chef/cookbooks/database/libraries/resource_sql_server_database.rb +34 -0
  136. data/chef/cookbooks/database/libraries/resource_sql_server_database_user.rb +34 -0
  137. data/chef/cookbooks/database/metadata.json +45 -0
  138. data/chef/cookbooks/database/metadata.rb +22 -0
  139. data/chef/cookbooks/database/recipes/default.rb +20 -0
  140. data/chef/cookbooks/database/recipes/ebs_backup.rb +89 -0
  141. data/chef/cookbooks/database/recipes/ebs_volume.rb +204 -0
  142. data/chef/cookbooks/database/recipes/master.rb +78 -0
  143. data/chef/cookbooks/database/recipes/mysql.rb +20 -0
  144. data/chef/cookbooks/database/recipes/postgresql.rb +20 -0
  145. data/chef/cookbooks/database/recipes/snapshot.rb +62 -0
  146. data/chef/cookbooks/database/templates/default/app_grants.sql.erb +8 -0
  147. data/chef/cookbooks/database/templates/default/aws_config.erb +3 -0
  148. data/chef/cookbooks/database/templates/default/chef-solo-database-snapshot.cron.erb +6 -0
  149. data/chef/cookbooks/database/templates/default/chef-solo-database-snapshot.json.erb +1 -0
  150. data/chef/cookbooks/database/templates/default/chef-solo-database-snapshot.rb.erb +6 -0
  151. data/chef/cookbooks/database/templates/default/ebs-backup-cron.erb +2 -0
  152. data/chef/cookbooks/database/templates/default/ebs-db-backup.sh.erb +8 -0
  153. data/chef/cookbooks/database/templates/default/ebs-db-restore.sh.erb +10 -0
  154. data/chef/cookbooks/database/templates/default/s3cfg.erb +27 -0
  155. data/chef/cookbooks/fast_food/recipes/default.rb +24 -0
  156. data/chef/cookbooks/fast_food/recipes/site.rb +7 -0
  157. data/chef/cookbooks/fast_food/templates/default/web_app.conf.erb +43 -0
  158. data/chef/cookbooks/git/CHANGELOG.md +49 -0
  159. data/chef/cookbooks/git/CONTRIBUTING +29 -0
  160. data/chef/cookbooks/git/LICENSE +201 -0
  161. data/chef/cookbooks/git/README.md +115 -0
  162. data/chef/cookbooks/git/attributes/default.rb +37 -0
  163. data/chef/cookbooks/git/metadata.json +48 -0
  164. data/chef/cookbooks/git/metadata.rb +20 -0
  165. data/chef/cookbooks/git/recipes/default.rb +46 -0
  166. data/chef/cookbooks/git/recipes/server.rb +38 -0
  167. data/chef/cookbooks/git/recipes/source.rb +48 -0
  168. data/chef/cookbooks/git/recipes/windows.rb +32 -0
  169. data/chef/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
  170. data/chef/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
  171. data/chef/cookbooks/imagemagick/README.md +57 -0
  172. data/chef/cookbooks/imagemagick/metadata.json +37 -0
  173. data/chef/cookbooks/imagemagick/metadata.rb +14 -0
  174. data/chef/cookbooks/imagemagick/recipes/default.rb +25 -0
  175. data/chef/cookbooks/imagemagick/recipes/devel.rb +32 -0
  176. data/chef/cookbooks/imagemagick/recipes/rmagick.rb +22 -0
  177. data/chef/cookbooks/mysql/.gitignore +5 -0
  178. data/chef/cookbooks/mysql/CHANGELOG.md +125 -0
  179. data/chef/cookbooks/mysql/CONTRIBUTING +29 -0
  180. data/chef/cookbooks/mysql/Gemfile +8 -0
  181. data/chef/cookbooks/mysql/LICENSE +201 -0
  182. data/chef/cookbooks/mysql/README.md +227 -0
  183. data/chef/cookbooks/mysql/attributes/client.rb +50 -0
  184. data/chef/cookbooks/mysql/attributes/server.rb +240 -0
  185. data/chef/cookbooks/mysql/files/default/tests/minitest/server_test.rb +36 -0
  186. data/chef/cookbooks/mysql/files/default/tests/minitest/support/helpers.rb +11 -0
  187. data/chef/cookbooks/mysql/libraries/helpers.rb +33 -0
  188. data/chef/cookbooks/mysql/metadata.json +418 -0
  189. data/chef/cookbooks/mysql/metadata.rb +140 -0
  190. data/chef/cookbooks/mysql/recipes/client.rb +59 -0
  191. data/chef/cookbooks/mysql/recipes/default.rb +20 -0
  192. data/chef/cookbooks/mysql/recipes/ruby.rb +36 -0
  193. data/chef/cookbooks/mysql/recipes/server.rb +221 -0
  194. data/chef/cookbooks/mysql/recipes/server_ec2.rb +51 -0
  195. data/chef/cookbooks/mysql/templates/default/debian.cnf.erb +12 -0
  196. data/chef/cookbooks/mysql/templates/default/grants.sql.erb +15 -0
  197. data/chef/cookbooks/mysql/templates/default/my.cnf.erb +312 -0
  198. data/chef/cookbooks/mysql/templates/default/mysql-server.seed.erb +10 -0
  199. data/chef/cookbooks/mysql/templates/default/port_mysql.erb +3 -0
  200. data/chef/cookbooks/mysql/templates/windows/my.cnf.erb +61 -0
  201. data/chef/cookbooks/openssl/README.md +37 -0
  202. data/chef/cookbooks/openssl/libraries/secure_password.rb +37 -0
  203. data/chef/cookbooks/openssl/metadata.json +30 -0
  204. data/chef/cookbooks/openssl/metadata.rb +8 -0
  205. data/chef/cookbooks/openssl/recipes/default.rb +19 -0
  206. data/chef/cookbooks/passenger_apache2/.gitignore +4 -0
  207. data/chef/cookbooks/passenger_apache2/CHANGELOG.md +29 -0
  208. data/chef/cookbooks/passenger_apache2/CONTRIBUTING +29 -0
  209. data/chef/cookbooks/passenger_apache2/Gemfile +3 -0
  210. data/chef/cookbooks/passenger_apache2/LICENSE +201 -0
  211. data/chef/cookbooks/passenger_apache2/README.md +77 -0
  212. data/chef/cookbooks/passenger_apache2/attributes/default.rb +5 -0
  213. data/chef/cookbooks/passenger_apache2/metadata.json +38 -0
  214. data/chef/cookbooks/passenger_apache2/metadata.rb +17 -0
  215. data/chef/cookbooks/passenger_apache2/recipes/default.rb +60 -0
  216. data/chef/cookbooks/passenger_apache2/recipes/mod_rails.rb +47 -0
  217. data/chef/cookbooks/passenger_apache2/templates/default/passenger.conf.erb +3 -0
  218. data/chef/cookbooks/passenger_apache2/templates/default/passenger.load.erb +1 -0
  219. data/chef/cookbooks/passenger_apache2/templates/default/passenger_web_app.conf.erb +32 -0
  220. data/chef/cookbooks/passenger_apache2/templates/default/web_app.conf.erb +32 -0
  221. data/chef/roles/apache2.rb +12 -0
  222. data/chef/roles/mysql.rb +18 -0
  223. data/chef/solo.rb +5 -0
  224. data/config/deploy/centos.sh +17 -0
  225. data/config/deploy/production.rb +3 -0
  226. data/config/deploy/ubuntu.sh +10 -0
  227. data/config/deploy.rb +99 -0
  228. data/config/deployment.yml +6 -0
  229. data/fast_food.gemspec +26 -0
  230. data/lib/fast_food/railtie.rb +9 -0
  231. data/lib/fast_food/version.rb +3 -0
  232. data/lib/fast_food.rb +5 -0
  233. data/lib/tasks/fast_food.rake +100 -0
  234. data/spec/lib/fast_food_spec.rb +0 -0
  235. data/spec/spec_helper.rb +1 -0
  236. metadata +349 -0
@@ -0,0 +1,204 @@
1
+ #
2
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
3
+ # Author:: AJ Christensen (<aj@opscode.com>)
4
+ # Cookbook Name:: database
5
+ # Recipe:: ebs_volume
6
+ #
7
+ # Copyright 2009-2010, Opscode, Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ if node[:ec2]
23
+ include_recipe "aws"
24
+ include_recipe "xfs"
25
+
26
+ begin
27
+ aws = Chef::DataBagItem.load(:aws, :main)
28
+ Chef::Log.info("Loaded AWS information from DataBagItem aws[#{aws['id']}]")
29
+ rescue
30
+ Chef::Log.fatal("Could not find the 'main' item in the 'aws' data bag")
31
+ raise
32
+ end
33
+
34
+ ebs_vol_dev = node['mysql']['ebs_vol_dev']
35
+ if (platform?("ubuntu") && node['platform_version'].to_f >= 11.04)
36
+ ebs_vol_dev_mount = ebs_vol_dev.sub(/^\/dev\/sd/, "/dev/xvd")
37
+ else
38
+ ebs_vol_dev_mount = ebs_vol_dev
39
+ end
40
+ ebs_vol_id = String.new
41
+ db_type = String.new
42
+ db_role = String.new
43
+ master_role = String.new
44
+ slave_role = String.new
45
+ root_pw = String.new
46
+ snapshots_to_keep = String.new
47
+ snapshot_cron_schedule = "00 * * * *" # default to hourly snapshots
48
+
49
+ search(:apps) do |app|
50
+ if (app["database_master_role"] & node.run_list.roles).length == 1 || (app["database_slave_role"] & node.run_list.roles).length == 1
51
+ master_role = app["database_master_role"] & node.run_list.roles
52
+ slave_role = app["database_slave_role"] & node.run_list.roles
53
+ root_pw = app["mysql_root_password"][node.chef_environment]
54
+ snapshots_to_keep = app["snapshots_to_keep"][node.chef_environment]
55
+ snapshot_cron_schedule = app["snapshot_cron_schedule"][node.chef_environment] if app["snapshot_cron_schedule"] && app["snapshot_cron_schedule"][node.chef_environment]
56
+
57
+ if (master_role & node.run_list.roles).length == 1
58
+ db_type = "master"
59
+ db_role = RUBY_VERSION.to_f <= 1.8 ? master_role : master_role.join
60
+ elsif (slave_role & node.run_list.roles).length == 1
61
+ db_type = "slave"
62
+ db_role = RUBY_VERSION.to_f <= 1.8 ? slave_role : slave_role.join
63
+ end
64
+
65
+ Chef::Log.info "database::ebs_volume - db_role: #{db_role} db_type: #{db_type}"
66
+ end
67
+ end
68
+
69
+ begin
70
+ ebs_info = Chef::DataBagItem.load(:aws, "ebs_#{db_role}_#{node.chef_environment}")
71
+ Chef::Log.info("Loaded #{ebs_info['volume_id']} from DataBagItem aws[#{ebs_info['id']}]")
72
+ rescue
73
+ Chef::Log.warn("Could not find the 'ebs_#{db_role}_#{node.chef_environment}' item in the 'aws' data bag")
74
+ ebs_info = Hash.new
75
+ end
76
+
77
+ begin
78
+ master_info = Chef::DataBagItem.load(:aws, "ebs_#{master_role}_#{node.chef_environment}")
79
+ Chef::Log.info "Loaded #{master_info['volume_id']} from DataBagItem aws[#{master_info['id']}]"
80
+ rescue
81
+ Chef::Application.fatal! "Could not load replication masters snapshot details", -41 if db_type == "slave"
82
+ end
83
+
84
+ ruby_block "store_#{db_role}_#{node.chef_environment}_volid" do
85
+ block do
86
+ ebs_vol_id = node[:aws][:ebs_volume]["#{db_role}_#{node.chef_environment}"][:volume_id]
87
+
88
+ unless ebs_info['volume_id']
89
+ item = {
90
+ "id" => "ebs_#{db_role}_#{node.chef_environment}",
91
+ "volume_id" => ebs_vol_id
92
+ }
93
+ Chef::Log.info "Storing volume_id #{item.inspect}"
94
+ databag_item = Chef::DataBagItem.new
95
+ databag_item.data_bag("aws")
96
+ databag_item.raw_data = item
97
+ databag_item.save
98
+ Chef::Log.info("Created #{item['id']} in #{databag_item.data_bag}")
99
+ end
100
+ end
101
+ action :nothing
102
+ end
103
+
104
+ aws_ebs_volume "#{db_role}_#{node.chef_environment}" do
105
+ aws_access_key aws['aws_access_key_id']
106
+ aws_secret_access_key aws['aws_secret_access_key']
107
+ size 50
108
+ device ebs_vol_dev
109
+ snapshots_to_keep snapshots_to_keep
110
+ case db_type
111
+ when "master"
112
+ if ebs_info['volume_id'] && ebs_info['volume_id'] =~ /vol/
113
+ volume_id ebs_info['volume_id']
114
+ action :attach
115
+ elsif ebs_info['volume_id'] && ebs_info['volume_id'] =~ /snap/
116
+ snapshot_id ebs_info['volume_id']
117
+ action [ :create, :attach ]
118
+ else
119
+ action [ :create, :attach ]
120
+ end
121
+ notifies :create, resources(:ruby_block => "store_#{db_role}_#{node.chef_environment}_volid")
122
+ when "slave"
123
+ if master_info['volume_id']
124
+ snapshot_id master_info['volume_id']
125
+ action [:create, :attach]
126
+ else
127
+ Chef::Log.warn("Couldn't detect snapshot ID.")
128
+ action :nothing
129
+ end
130
+ end
131
+ provider "aws_ebs_volume"
132
+ end
133
+
134
+ if db_type == "master"
135
+ Chef::Log.info "Setting up templates for chef-solo snapshots"
136
+ template "/etc/chef/chef-solo-database-snapshot.rb" do
137
+ source "chef-solo-database-snapshot.rb.erb"
138
+ variables :cookbook_path => Chef::Config[:cookbook_path]
139
+ owner "root"
140
+ group "root"
141
+ mode 0600
142
+ end
143
+
144
+ template "/etc/chef/chef-solo-database-snapshot.json" do
145
+ source "chef-solo-database-snapshot.json.erb"
146
+ variables(
147
+ :output => {
148
+ 'db_snapshot' => {
149
+ 'ebs_vol_dev' => node.mysql.ec2_path,
150
+ 'db_role' => db_role,
151
+ 'app_environment' => node.chef_environment,
152
+ 'username' => 'root',
153
+ 'password' => root_pw,
154
+ 'aws_access_key_id' => aws['aws_access_key_id'],
155
+ 'aws_secret_access_key' => aws['aws_secret_access_key'],
156
+ 'snapshots_to_keep' => snapshots_to_keep,
157
+ 'volume_id' => ebs_info['volume_id']
158
+ },
159
+ 'run_list' => [
160
+ "recipe[database::snapshot]"
161
+ ]
162
+ }
163
+ )
164
+ owner "root"
165
+ group "root"
166
+ mode 0600
167
+ end
168
+
169
+ template "/etc/cron.d/chef-solo-database-snapshot" do
170
+ source "chef-solo-database-snapshot.cron.erb"
171
+ variables(
172
+ :json_attribs => "/etc/chef/chef-solo-database-snapshot.json",
173
+ :config_file => "/etc/chef/chef-solo-database-snapshot.rb",
174
+ :schedule => snapshot_cron_schedule
175
+ )
176
+ owner "root"
177
+ group "root"
178
+ mode 0600
179
+ end
180
+ end
181
+
182
+ execute "mkfs.xfs #{ebs_vol_dev_mount}" do
183
+ only_if "xfs_admin -l #{ebs_vol_dev_mount} 2>&1 | grep -qx 'xfs_admin: #{ebs_vol_dev_mount} is not a valid XFS filesystem (unexpected SB magic number 0x00000000)'"
184
+ end
185
+
186
+ %w{ec2_path data_dir}.each do |dir|
187
+ directory node['mysql'][dir] do
188
+ mode 0755
189
+ end
190
+ end
191
+
192
+ mount node['mysql']['ec2_path'] do
193
+ device ebs_vol_dev_mount
194
+ fstype "xfs"
195
+ action :mount
196
+ end
197
+
198
+ mount node['mysql']['data_dir'] do
199
+ device node['mysql']['ec2_path']
200
+ fstype "none"
201
+ options "bind,rw"
202
+ action :mount
203
+ end
204
+ end
@@ -0,0 +1,78 @@
1
+ #
2
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
3
+ # Cookbook Name:: database
4
+ # Recipe:: master
5
+ #
6
+ # Copyright 2009-2010, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # This is potentially destructive to the nodes mysql password attributes, since
21
+ # we iterate over all the app databags. If this database server provides
22
+ # databases for multiple applications, the last app found in the databags
23
+ # will win out, so make sure the databags have the same passwords set for
24
+ # the root, repl, and debian-sys-maint users.
25
+ #
26
+
27
+ db_info = Hash.new
28
+ root_pw = String.new
29
+
30
+ search(:apps) do |app|
31
+ (app['database_master_role'] & node.run_list.roles).each do |dbm_role|
32
+ %w{ root repl debian }.each do |user|
33
+ user_pw = app["mysql_#{user}_password"]
34
+ if !user_pw.nil? and user_pw[node.chef_environment]
35
+ Chef::Log.debug("Saving password for #{user} as node attribute node['mysql']['server_#{user}_password'")
36
+ node.set['mysql']["server_#{user}_password"] = user_pw[node.chef_environment]
37
+ node.save
38
+ else
39
+ log "A password for MySQL user #{user} was not found in DataBag 'apps' item '#{app["id"]}' for environment ' for #{node.chef_environment}'." do
40
+ level :warn
41
+ end
42
+ log "A random password will be generated by the mysql cookbook and added as 'node.mysql.server_#{user}_password'. Edit the DataBag item to ensure it is set correctly on new nodes" do
43
+ level :warn
44
+ end
45
+ end
46
+ end
47
+ app['databases'].each do |env,db|
48
+ db_info[env] = db
49
+ end
50
+ end
51
+ end
52
+
53
+ include_recipe "mysql::server"
54
+
55
+ connection_info = {:host => "localhost", :username => 'root', :password => node['mysql']['server_root_password']}
56
+
57
+ search(:apps) do |app|
58
+ (app['database_master_role'] & node.run_list.roles).each do |dbm_role|
59
+ app['databases'].each do |env,db|
60
+ if env =~ /#{node.chef_environment}/
61
+ mysql_database "create #{db['database']}" do
62
+ database_name db['database']
63
+ connection connection_info
64
+ action :create
65
+ end
66
+ %W{ % #{node['fqdn']} localhost }.each do |h|
67
+ mysql_database_user db['username'] do
68
+ connection connection_info
69
+ password db['password']
70
+ database_name db['database']
71
+ host h
72
+ action :grant
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Author:: Jesse Howarth (<him@jessehowarth.com>)
3
+ #
4
+ # Copyright:: Copyright (c) 2012, Opscode, Inc. (<legal@opscode.com>)
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "mysql::ruby"
@@ -0,0 +1,20 @@
1
+ #
2
+ # Author:: Jesse Howarth (<him@jessehowarth.com>)
3
+ #
4
+ # Copyright:: Copyright (c) 2012, Opscode, Inc. (<legal@opscode.com>)
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "postgresql::ruby"
@@ -0,0 +1,62 @@
1
+ #
2
+ # Author:: AJ Christensen (<aj@opscode.com>)
3
+ # Cookbook Name:: database
4
+ # Recipe:: snapshot
5
+ #
6
+ # Copyright 2009-2010, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ include_recipe "aws"
21
+ include_recipe "xfs"
22
+
23
+ %w{ebs_vol_dev db_role app_environment username password aws_access_key_id aws_secret_access_key snapshots_to_keep volume_id}.collect do |key|
24
+ Chef::Application.fatal!("Required db_snapshot configuration #{key} not found.", -47) unless node.db_snapshot.has_key? key
25
+ end
26
+
27
+ connection_info = {:host => "localhost", :username => node.db_snapshot.username, :password => node.db_snapshot.password}
28
+
29
+ mysql_database "locking tables for #{node.db_snapshot.app_environment}" do
30
+ connection connection_info
31
+ sql "flush tables with read lock"
32
+ action :query
33
+ end
34
+
35
+ execute "xfs freeze" do
36
+ command "xfs_freeze -f #{node.db_snapshot.ebs_vol_dev}"
37
+ end
38
+
39
+ aws_ebs_volume "#{node.db_snapshot.db_role.first}_#{node.db_snapshot.app_environment}" do
40
+ aws_access_key node.db_snapshot.aws_access_key_id
41
+ aws_secret_access_key node.db_snapshot.aws_secret_access_key
42
+ size 50
43
+ device node.db_snapshot.ebs_vol_dev
44
+ snapshots_to_keep node.db_snapshot.snapshots_to_keep
45
+ action :snapshot
46
+ volume_id node.db_snapshot.volume_id
47
+ ignore_failure true # if this fails, continue to unfreeze and unlock
48
+ end
49
+
50
+ execute "xfs unfreeze" do
51
+ command "xfs_freeze -u #{node.db_snapshot.ebs_vol_dev}"
52
+ end
53
+
54
+ mysql_database "unflushing tables for #{node.db_snapshot.app_environment}" do
55
+ connection connection_info
56
+ sql "unlock tables"
57
+ action :query
58
+ end
59
+
60
+ aws_ebs_volume "#{node.db_snapshot.db_role.first}_#{node.db_snapshot.app_environment}" do
61
+ action :prune
62
+ end
@@ -0,0 +1,8 @@
1
+ # Generated by Chef. Local modifications will be overwritten.
2
+ <% @db_info.each do |env,db| -%>
3
+ # Privileges for databases in <%= env %>
4
+ GRANT ALL ON <%= db['database'] %>.* TO '<%= db['username'] %>'@'localhost' IDENTIFIED BY '<%= db['password'] %>';
5
+ GRANT ALL ON <%= db['database'] %>.* TO '<%= db['username'] %>'@'<%= node['fqdn'] %>' IDENTIFIED BY '<%= db['password'] %>';
6
+ GRANT ALL ON <%= db['database'] %>.* TO '<%= db['username'] %>'@'%' IDENTIFIED BY '<%= db['password'] %>';
7
+ <% end -%>
8
+ flush privileges;
@@ -0,0 +1,3 @@
1
+ AWS_ACCESS_KEY_ID=<%= @access_key %>
2
+ AWS_SECRET_ACCESS_KEY=<%= @secret_key %>
3
+ BUCKET_BASE_NAME=db-backups
@@ -0,0 +1,6 @@
1
+ # Managed by Chef
2
+ # m h dom mon dow command
3
+ # Keep 1 day of hourly snapshots
4
+ PATH=/usr/sbin:/usr/bin:/sbin:/bin
5
+ <% cs = "chef-solo -j #{@json_attribs} -c #{@config_file}" %>
6
+ <%= @schedule %> root <%= cs %>
@@ -0,0 +1 @@
1
+ <%= require 'json'; JSON.pretty_generate(@output) %>
@@ -0,0 +1,6 @@
1
+ executable_path ENV['PATH'] ? ENV['PATH'].split(File::PATH_SEPARATOR) : []
2
+ <% if @cookbook_path.is_a? Array %>
3
+ cookbook_path [ <%= @cookbook_path.collect { |cb| "\"#{cb}\""}.join(", ") -%> ]
4
+ <% else %>
5
+ cookbook_path "<%= @cookbook_path -%>"
6
+ <% end %>
@@ -0,0 +1,2 @@
1
+ # Chef Name: ebs_db_backup
2
+ 15 0 * * * root /usr/local/bin/db-backup.sh
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ #
3
+ # Back up a MySQL database via EBS snapshot
4
+
5
+ . /mnt/aws-config/config
6
+
7
+ /opt/ec2_mysql/bin/ec2_mysql -a $AWS_ACCESS_KEY_ID -s $AWS_SECRET_ACCESS_KEY -p '<%= @mysql_root_passwd %>' -k 5 master
8
+ echo "done"
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ #
3
+ # Restore a MySQL database from EBS
4
+
5
+ mkdir -p /mnt/restore
6
+
7
+ . /mnt/aws-config/config
8
+
9
+ /opt/ec2_mysql/bin/ec2_mysql -a $AWS_ACCESS_KEY_ID -s $AWS_SECRET_ACCESS_KEY -p '<%= @mysql_root_password %>' -v '<%= @ebs_vol_id %>' -m /mnt/restore -d <%= @mysql_device %> -r <%= @mysql_device %> -l debug -n slave
10
+ echo "done"
@@ -0,0 +1,27 @@
1
+ [default]
2
+ access_key = <%= @aws['aws_access_key_id'] %>
3
+ acl_public = False
4
+ bucket_location = US
5
+ debug_syncmatch = False
6
+ default_mime_type = binary/octet-stream
7
+ delete_removed = False
8
+ dry_run = False
9
+ encrypt = False
10
+ force = False
11
+ gpg_command = /usr/bin/gpg
12
+ gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
13
+ gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
14
+ gpg_passphrase =
15
+ guess_mime_type = False
16
+ host_base = s3.amazonaws.com
17
+ host_bucket = %(bucket)s.s3.amazonaws.com
18
+ human_readable_sizes = False
19
+ preserve_attrs = True
20
+ proxy_host =
21
+ proxy_port = 0
22
+ recv_chunk = 4096
23
+ secret_key = <%= @aws['aws_secret_access_key'] %>
24
+ send_chunk = 4096
25
+ simpledb_host = sdb.amazonaws.com
26
+ use_https = True
27
+ verbosity = WARNING
@@ -0,0 +1,24 @@
1
+ include_recipe "imagemagick"
2
+ include_recipe "imagemagick::devel"
3
+ include_recipe "database::mysql"
4
+ include_recipe "git"
5
+ include_recipe "passenger_apache2"
6
+ include_recipe "passenger_apache2::mod_rails"
7
+
8
+ # create a mysql database
9
+ mysql_database node['mysql']['database'] do
10
+ connection ({:host => node['mysql']['hostname'], :username => "root", :password => node['mysql']['server_root_password']})
11
+ action :create
12
+ end
13
+
14
+ mysql_database_user node['mysql']['username'] do
15
+ connection ({:host => node['mysql']['hostname'], :username => "root", :password => node['mysql']['server_root_password']})
16
+ password node['mysql']['password']
17
+ action :create
18
+ end
19
+
20
+ mysql_database_user node['mysql']['username'] do
21
+ connection ({:host => node['mysql']['hostname'], :username => "root", :password => node['mysql']['server_root_password']})
22
+ password node['mysql']['password']
23
+ action :grant
24
+ end
@@ -0,0 +1,7 @@
1
+ include_recipe "apache2"
2
+
3
+ web_app node['site']['name'] do
4
+ server_name node['site']['server_name']
5
+ server_aliases node['site']['server_aliases']
6
+ docroot node["site"]["docroot"]
7
+ end
@@ -0,0 +1,43 @@
1
+ <VirtualHost *:80>
2
+ ServerName <%= @params[:server_name] %>
3
+ ServerAlias <% @params[:server_aliases].each do |a| %><%= "#{a}" %> <% end %>
4
+ DocumentRoot <%= @params[:docroot] %>
5
+ RewriteEngine On
6
+
7
+ <Directory <%= @params[:docroot] %>>
8
+ Options FollowSymLinks
9
+ AllowOverride None
10
+ Order allow,deny
11
+ Allow from all
12
+ </Directory>
13
+
14
+ <Directory />
15
+ Options FollowSymLinks
16
+ AllowOverride None
17
+ </Directory>
18
+
19
+ <Location /server-status>
20
+ SetHandler server-status
21
+
22
+ Order Deny,Allow
23
+ Deny from all
24
+ Allow from 127.0.0.1
25
+ </Location>
26
+
27
+ LogLevel info
28
+ ErrorLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-error.log
29
+ CustomLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-access.log combined
30
+
31
+ RewriteEngine On
32
+ RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log
33
+ RewriteLogLevel 0
34
+
35
+ # Canonical host, <%= @params[:server_name] %>
36
+ RewriteCond %{HTTP_HOST} !^<%= @params[:server_name] %> [NC]
37
+ RewriteCond %{HTTP_HOST} !^$
38
+ RewriteRule ^/(.*)$ http://<%= @params[:server_name] %>/$1 [L,R=301]
39
+
40
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
41
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
42
+ RewriteRule ^.*$ /system/maintenance.html [L]
43
+ </VirtualHost>
@@ -0,0 +1,49 @@
1
+ ## v2.1.2:
2
+
3
+ * [COOK-2043] - install git on ubuntu 12.04 not git-core
4
+
5
+ ## v2.1.0:
6
+
7
+ The repository didn't have pushed commits, and so the following
8
+ changes from earlier-than-latest versions wouldn't be available on the
9
+ community site. We're releasing 2.1.0 to correct this.
10
+
11
+ * [COOK-1943] - Update to git 1.8.0
12
+ * [COOK-2020] - Add setup option attributes to Git Windows package
13
+ install
14
+
15
+ ## v2.0.0:
16
+
17
+ This version uses platform_family attribute, making the cookbook incompatible
18
+ with older versions of Chef/Ohai, hence the major version bump.
19
+
20
+ * [COOK-1668] - git cookbook fails to run due to bad platform_family
21
+ call
22
+ * [COOK-1759] - git::source needs additional package for rhel
23
+ platform_family
24
+
25
+ ## v1.1.2:
26
+
27
+ * [COOK-2020] - Add setup option attributes to Git Windows package
28
+ install
29
+
30
+ ## v1.1.0:
31
+
32
+ * [COOK-1943] - Update to git 1.8.0
33
+
34
+ ## v1.0.2:
35
+
36
+ * [COOK-1537] - add recipe for source installation
37
+
38
+ ## v1.0.0:
39
+
40
+ * [COOK-1152] - Add support for Mac OS X
41
+ * [COOK-1112] - Add support for Windows
42
+
43
+ ## v0.10.0:
44
+
45
+ * [COOK-853] - Git client installation on CentOS
46
+
47
+ ## v0.9.0:
48
+
49
+ * Current public release.
@@ -0,0 +1,29 @@
1
+ If you would like to contribute, please open a ticket in JIRA:
2
+
3
+ * http://tickets.opscode.com
4
+
5
+ Create the ticket in the COOK project and use the cookbook name as the
6
+ component.
7
+
8
+ For all code contributions, we ask that contributors sign a
9
+ contributor license agreement (CLA). Instructions may be found here:
10
+
11
+ * http://wiki.opscode.com/display/chef/How+to+Contribute
12
+
13
+ When contributing changes to individual cookbooks, please do not
14
+ modify the version number in the metadata.rb. Also please do not
15
+ update the CHANGELOG.md for a new version. Not all changes to a
16
+ cookbook may be merged and released in the same versions. Opscode will
17
+ handle the version updates during the release process. You are welcome
18
+ to correct typos or otherwise make updates to documentation in the
19
+ README.
20
+
21
+ If a contribution adds new platforms or platform versions, indicate
22
+ such in the body of the commit message(s), and update the relevant
23
+ COOK ticket. When writing commit messages, it is helpful for others if
24
+ you indicate the COOK ticket. For example:
25
+
26
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
27
+
28
+ In the ticket itself, it is also helpful if you include log output of
29
+ a successful Chef run, but this is not absolutely required.