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,119 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/resource'
20
+
21
+ class Chef
22
+ class Resource
23
+ class Database < Chef::Resource
24
+
25
+ def initialize(name, run_context=nil)
26
+ super
27
+ @resource_name = :database
28
+ @database_name = name
29
+ @allowed_actions.push(:create, :drop, :query)
30
+ @action = :create
31
+ end
32
+
33
+ def database_name(arg=nil)
34
+ set_or_return(
35
+ :database_name,
36
+ arg,
37
+ :kind_of => String
38
+ )
39
+ end
40
+
41
+ def connection(arg=nil)
42
+ set_or_return(
43
+ :connection,
44
+ arg,
45
+ :required => true
46
+ )
47
+ end
48
+
49
+ def sql(arg=nil, &block)
50
+ arg ||= block
51
+ set_or_return(
52
+ :sql,
53
+ arg,
54
+ :kind_of => [String, Proc]
55
+ )
56
+ end
57
+
58
+ def sql_query
59
+ if sql.kind_of?(Proc)
60
+ sql.call
61
+ else
62
+ sql
63
+ end
64
+ end
65
+
66
+ def template(arg=nil)
67
+ set_or_return(
68
+ :template,
69
+ arg,
70
+ :kind_of => String,
71
+ :default => 'DEFAULT'
72
+ )
73
+ end
74
+
75
+ def collation(arg=nil)
76
+ set_or_return(
77
+ :collation,
78
+ arg,
79
+ :kind_of => String
80
+ )
81
+ end
82
+
83
+ def encoding(arg=nil)
84
+ set_or_return(
85
+ :encoding,
86
+ arg,
87
+ :kind_of => String,
88
+ :default => 'DEFAULT'
89
+ )
90
+ end
91
+
92
+ def tablespace(arg=nil)
93
+ set_or_return(
94
+ :tablespace,
95
+ arg,
96
+ :kind_of => String,
97
+ :default => 'DEFAULT'
98
+ )
99
+ end
100
+
101
+ def connection_limit(arg=nil)
102
+ set_or_return(
103
+ :connection_limit,
104
+ arg,
105
+ :kind_of => String,
106
+ :default => '-1'
107
+ )
108
+ end
109
+
110
+ def owner(arg=nil)
111
+ set_or_return(
112
+ :owner,
113
+ arg,
114
+ :kind_of => String
115
+ )
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,90 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), 'resource_database')
20
+
21
+ class Chef
22
+ class Resource
23
+ class DatabaseUser < Chef::Resource::Database
24
+
25
+ def initialize(name, run_context=nil)
26
+ super
27
+ @resource_name = :database_user
28
+ @username = name
29
+
30
+ @database_name = nil
31
+ @table = nil
32
+ @host = 'localhost'
33
+ @privileges = [:all]
34
+
35
+ @allowed_actions.push(:create, :drop, :grant)
36
+ @action = :create
37
+ end
38
+
39
+ def database_name(arg=nil)
40
+ set_or_return(
41
+ :database_name,
42
+ arg,
43
+ :kind_of => String
44
+ )
45
+ end
46
+
47
+ def username(arg=nil)
48
+ set_or_return(
49
+ :username,
50
+ arg,
51
+ :kind_of => String
52
+ )
53
+ end
54
+
55
+ def password(arg=nil)
56
+ set_or_return(
57
+ :password,
58
+ arg,
59
+ :kind_of => String,
60
+ :required => true
61
+ )
62
+ end
63
+
64
+ def table(arg=nil)
65
+ set_or_return(
66
+ :table,
67
+ arg,
68
+ :kind_of => String
69
+ )
70
+ end
71
+
72
+ def host(arg=nil)
73
+ set_or_return(
74
+ :host,
75
+ arg,
76
+ :kind_of => String
77
+ )
78
+ end
79
+
80
+ def privileges(arg=nil)
81
+ set_or_return(
82
+ :privileges,
83
+ arg,
84
+ :kind_of => Array
85
+ )
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), 'resource_database')
20
+ require File.join(File.dirname(__FILE__), 'provider_database_mysql')
21
+
22
+ class Chef
23
+ class Resource
24
+ class MysqlDatabase < Chef::Resource::Database
25
+
26
+ def initialize(name, run_context=nil)
27
+ super
28
+ @resource_name = :mysql_database
29
+ @provider = Chef::Provider::Database::Mysql
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), 'resource_database_user')
20
+ require File.join(File.dirname(__FILE__), 'provider_database_mysql_user')
21
+
22
+ class Chef
23
+ class Resource
24
+ class MysqlDatabaseUser < Chef::Resource::DatabaseUser
25
+
26
+ def initialize(name, run_context=nil)
27
+ super
28
+ @resource_name = :mysql_database_user
29
+ @provider = Chef::Provider::Database::MysqlUser
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Author:: Lamont Granquist (<lamont@opscode.com>)
4
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
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
+ require File.join(File.dirname(__FILE__), 'resource_database')
21
+ require File.join(File.dirname(__FILE__), 'provider_database_postgresql')
22
+
23
+ class Chef
24
+ class Resource
25
+ class PostgresqlDatabase < Chef::Resource::Database
26
+
27
+ def initialize(name, run_context=nil)
28
+ super
29
+ @resource_name = :postgresql_database
30
+ @provider = Chef::Provider::Database::Postgresql
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Author:: Lamont Granquist (<lamont@opscode.com>)
4
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
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
+ require File.join(File.dirname(__FILE__), 'resource_database_user')
21
+ require File.join(File.dirname(__FILE__), 'provider_database_postgresql_user')
22
+
23
+ class Chef
24
+ class Resource
25
+ class PostgresqlDatabaseUser < Chef::Resource::DatabaseUser
26
+
27
+ def initialize(name, run_context=nil)
28
+ super
29
+ @resource_name = :postgresql_database_user
30
+ @provider = Chef::Provider::Database::PostgresqlUser
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), 'resource_database')
20
+ require File.join(File.dirname(__FILE__), 'provider_database_sql_server')
21
+
22
+ class Chef
23
+ class Resource
24
+ class SqlServerDatabase < Chef::Resource::Database
25
+
26
+ def initialize(name, run_context=nil)
27
+ super
28
+ @resource_name = :sql_server_database
29
+ @provider = Chef::Provider::Database::SqlServer
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.join(File.dirname(__FILE__), 'resource_database_user')
20
+ require File.join(File.dirname(__FILE__), 'provider_database_sql_server_user')
21
+
22
+ class Chef
23
+ class Resource
24
+ class SqlServerDatabaseUser < Chef::Resource::DatabaseUser
25
+
26
+ def initialize(name, run_context=nil)
27
+ super
28
+ @resource_name = :sql_server_database_user
29
+ @provider = Chef::Provider::Database::SqlServerUser
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "database",
3
+ "description": "Sets up the database master or slave",
4
+ "long_description": "Database Cookbook\n=================\n\nThe main highlight of this cookbook is the `database` and\n`database_user` resources for managing databases and database users in\na RDBMS. Providers for MySQL, PostgreSQL and SQL Server are also\nprovided, see usage documentation below.\n\nThis cookbook also contains recipes to configure mysql database\nmasters and slaves and uses EBS for storage, integrating together with\nthe application cookbook utilizing data bags for application related\ninformation. These recipes are written primarily to use MySQL and the\nOpscode mysql cookbook. Other RDBMS may be supported at a later date.\nThis cookbook does not automatically restore database dumps, but does\ninstall tools to help with that.\n\nRequirements\n============\n\nChef version 0.10.10+.\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* Red Hat, CentOS, Scientific, Fedora\n\nCookbooks\n---------\n\nThe following Opscode cookbooks are dependencies:\n\n* mysql\n* postgresql\n* xfs\n* aws\n\nResources/Providers\n===================\n\nThese resources aim to expose an abstraction layer for interacting\nwith different RDBMS in a general way. Currently the cookbook ships\nwith providers for MySQL, PostgreSQL and SQL Server. Please see\nspecific usage in the __Example__ sections below. The providers use\nspecific Ruby gems installed under Chef's Ruby environment to execute\ncommands and carry out actions. These gems will need to be installed\nbefore the providers can operate correctly. Specific notes for each\nRDBS flavor:\n\n- MySQL: leverages the `mysql` gem which is installed as part of the\n `mysql::ruby` recipe. You can use `database::mysql` to include this,\n too.\n- PostgreSQL: leverages the `pg` gem which is installed as part of the\n `postgresql::ruby` recipe. You can use `database::postgresql` to\n include this, too.\n Currently does not work in Chef \"omnibus\" full stack installs, see COOK-1406.\n- SQL Server: leverages the `tiny_tds` gem which is installed as part\n of the `sql_server::client` recipe.\n\n`database`\n----------\n\nManage databases in a RDBMS. Use the proper shortcut resource\ndepending on your RDBMS: `mysql_database`, `postgresql_database` or\n`sql_server_database`.\n\n### Actions\n\n- :create: create a named database\n- :drop: drop a named database\n- :query: execute an arbitrary query against a named database\n\n### Attribute Parameters\n\n- database_name: name attribute. Name of the database to interact with\n- connection: hash of connection info. valid keys include :host,\n :port, :username, :password\n- sql: string of sql or a block that executes to a string of sql,\n which will be executed against the database. used by :query action\n only\n\n### Providers\n\n- **Chef::Provider::Database::Mysql**: shortcut resource `mysql_database`\n- **Chef::Provider::Database::Postgresql**: shortcut resource `postgresql_database`\n- **Chef::Provider::Database::SqlServer**: shortcut resource `sql_server_database`\n\n### Examples\n\n # create a mysql database\n mysql_database 'oracle_rules' do\n connection ({:host => \"localhost\", :username => 'root', :password => node['mysql']['server_root_password']})\n action :create\n end\n\n # create a sql server database\n sql_server_database 'mr_softie' do\n connection ({:host => \"127.0.0.1\", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']})\n action :create\n end\n\n # create a postgresql database\n postgresql_database 'mr_softie' do\n connection ({:host => \"127.0.0.1\", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']})\n action :create\n end\n\n # create a postgresql database with additional parameters\n postgresql_database 'mr_softie' do\n connection ({:host => \"127.0.0.1\", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']})\n template 'DEFAULT'\n encoding 'DEFAULT'\n tablespace 'DEFAULT'\n connection_limit '-1'\n owner 'postgres'\n action :create\n end\n\n # externalize conection info in a ruby hash\n mysql_connection_info = {:host => \"localhost\", :username => 'root', :password => node['mysql']['server_root_password']}\n sql_server_connection_info = {:host => \"localhost\", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']}\n postgresql_connection_info = {:host => \"127.0.0.1\", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']}\n\n # same create commands, connection info as an external hash\n mysql_database 'foo' do\n connection mysql_connection_info\n action :create\n end\n sql_server_database 'foo' do\n connection sql_server_connection_info\n action :create\n end\n postgresql_database 'foo' do\n connection postgresql_connection_info\n action :create\n end\n\n # create database, set provider in resource parameter\n database 'bar' do\n connection mysql_connection_info\n provider Chef::Provider::Database::Mysql\n action :create\n end\n database 'bar' do\n connection sql_server_connection_info\n provider Chef::Provider::Database::SqlServer\n action :create\n end\n database 'bar' do\n connection postgresql_connection_info\n provider Chef::Provider::Database::Postgresql\n action :create\n end\n\n # drop a database\n mysql_database \"baz\" do\n connection mysql_connection_info\n action :drop\n end\n\n # query a database\n mysql_database \"flush the privileges\" do\n connection mysql_connection_info\n sql \"flush privileges\"\n action :query\n end\n\n # query a database from a sql script on disk\n mysql_database \"run script\" do\n connection mysql_connection_info\n sql { ::File.open(\"/path/to/sql_script.sql\").read }\n action :query\n end\n\n # vacuum a postgres database\n postgres_database \"vacuum databases\" do\n connection postgresql_connection_info\n database_table \"template1\"\n sql \"VACUUM FULL VERBOSE ANALYZE\"\n action :query\n end\n\n`database_user`\n---------------\n\nManage users and user privileges in a RDBMS. Use the proper shortcut\nresource depending on your RDBMS: `mysql_database_user` or\n`sql_server_database_user`.\n\n### Actions\n\n- :create: create a user\n- :drop: drop a user\n- :grant: manipulate user privileges on database objects\n\n### Attribute Parameters\n\n- username: name attribute. Name of the database user\n- password: password for the user account\n- database_name: Name of the database to interact with\n- connection: hash of connection info. valid keys include :host,\n :port, :username, :password\n- privileges: array of database privileges to grant user. used by the\n :grant action. default is :all\n- host: host where user connections are allowed from. used by MySQL\n provider only. default is 'localhost'\n- table: table to grant privileges on. used by :grant action and MySQL\n provider only. default is '*' (all tables)\n\n### Providers\n\n- **Chef::Provider::Database::MysqlUser**: shortcut resource\n `mysql_database_user`\n- **Chef::Provider::Database::SqlServerUser**: shortcut resource\n `sql_server_database_user`\n\n### Examples\n\n # create connection info as an external ruby hash\n mysql_connection_info = {:host => \"localhost\", :username => 'root', :password => node['mysql']['server_root_password']}\n sql_server_connection_info = {:host => \"localhost\", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']}\n\n # create a mysql user but grant no priveleges\n mysql_database_user 'disenfranchised' do\n connection mysql_connection_info\n password 'super_secret'\n action :create\n end\n\n # do the same but pass the provider to the database resource\n database_user 'disenfranchised' do\n connection mysql_connection_info\n password 'super_secret'\n provider Chef::Provider::Database::MysqlUser\n action :create\n end\n\n # create a sql server user but grant no priveleges\n sql_server_database_user 'disenfranchised' do\n connection sql_server_connection_info\n password 'super_secret'\n action :create\n end\n\n # drop a mysql user\n mysql_database_user \"foo_user\" do\n connection mysql_connection_info\n action :drop\n ends\n\n # bulk drop sql server users\n %w{ disenfranchised foo_user }.each do |user|\n sql_server_database_user user do\n connection sql_server_connection_info\n action :drop\n end\n end\n\n # grant select,update,insert privileges to all tables in foo db from all hosts\n mysql_database_user 'foo_user' do\n connection mysql_connection_info\n password 'super_secret'\n database_name 'foo'\n host '%'\n privileges [:select,:update,:insert]\n action :grant\n end\n\n # grant all privelages on all databases/tables from localhost\n mysql_database_user 'super_user' do\n connection mysql_connection_info\n password 'super_secret'\n action :grant\n end\n\n # grant select,update,insert privileges to all tables in foo db\n sql_server_database_user 'foo_user' do\n connection sql_server_connection_info\n password 'super_secret'\n database_name 'foo'\n privileges [:select,:update,:insert]\n action :grant\n end\n\nRecipes\n=======\n\nebs\\_volume\n-----------\n\n*Note*: This recipe does not currently work on RHEL platforms due to\n the xfs cookbook not supporting RHEL yet.\n\nLoads the aws information from the data bag. Searches the applications\ndata bag for the database master or slave role and checks that role is\napplied to the node. Loads the EBS information and the master\ninformation from data bags. Uses the aws cookbook LWRP,\n`aws_ebs_volume` to manage the volume.\n\nOn a master node:\n* if we have an ebs volume already as stored in a data bag, attach it.\n* if we don't have the ebs information then create a new one and\n attach it.\n* store the volume information in a data bag via a ruby block.\n\nOn a slave node:\n* use the master volume information to generate a snapshot.\n* create the new volume from the snapshot and attach it.\n\nAlso on a master node, generate some configuration for running a\nsnapshot via `chef-solo` from cron.\n\nOn a new filesystem volume, create as XFS, then mount it in /mnt, and\nalso bind-mount it to the mysql data directory (default\n/var/lib/mysql).\n\nmaster\n------\n\nThis recipe no longer loads AWS specific information, and the database\nposition for replication is no longer stored in a databag because the\nclient might not have permission to write to the databag item. This\nmay be handled in a different way at a future date.\n\nSearches the apps databag for applications, and for each one it will\ncheck that the specified database master role is set in both the\ndatabag and applied to the node's run list. Then, retrieves the\npasswords for `root`, `repl` and `debian` users and saves them to the\nnode attributes. If the passwords are not found in the databag, it\nprints a message that they'll be generated by the mysql cookbook.\n\nThen it adds the application databag database settings to a hash, to\nuse later.\n\nThen it will iterate over the databases and create them with the\n`mysql_database` resource while adding privileges for application\nspecific database users using the `mysql_database_user` resource.\n\nslave\n-----\n\n_TODO_: Retrieve the master status from a data bag, then start\nreplication using a ruby block. The replication status needs to be\nhandled in some other way for now since the master recipe above\ndoesn't actually set it in the databag anymore.\n\nsnapshot\n--------\n\nRun via Chef Solo. Retrieves the db snapshot configuration from the\nspecified JSON file. Uses the `mysql_database` resource to lock and\nunlock tables, and does a filesystem freeze and EBS snapshot.\n\nDeprecated Recipes\n==================\n\nThe following recipe is considered deprecated. It is kept for\nreference purposes.\n\nebs\\_backup\n-----------\n\nOlder style of doing mysql snapshot and replication using Adam Jacob's\n[ec2_mysql](http://github.com/adamhjk/ec2_mysql) script and library.\n\nData Bags\n=========\n\nThis cookbook uses the apps data bag item for the specified\napplication; see the `application` cookbook's README.md. It also\ncreates data bag items in a bag named 'aws' for storing volume\ninformation. In order to interact with EC2, it expects aws to have a\nmain item:\n\n {\n \"id\": \"main\",\n \"ec2_private_key\": \"private key as a string\",\n \"ec2_cert\": \"certificate as a string\",\n \"aws_account_id\": \"\",\n \"aws_secret_access_key\": \"\",\n \"aws_access_key_id\": \"\"\n }\n\nNote: with the Open Source Chef Server, the server using the database\nrecipes must be an admin client or it will not be able to create data\nbag items. You can modify whether the client is admin by editing it\nwith knife.\n\n knife client edit <client_name>\n {\n ...\n \"admin\": true\n ...\n }\n\nThis is not required if the Chef Server is Opscode Hosted Chef,\ninstead use the ACL feature to modify access for the node to be able\nto update the data bag.\n\nUsage\n=====\n\nAside from the application data bag (see the README in the application\ncookbook), create a role for the database master. Use a role.rb in\nyour chef-repo, or create the role directly with knife.\n\n % knife role show my_app_database_master -Fj\n {\n \"name\": \"my_app_database_master\",\n \"chef_type\": \"role\",\n \"json_class\": \"Chef::Role\",\n \"default_attributes\": {\n },\n \"description\": \"\",\n \"run_list\": [\n \"recipe[mysql::server]\",\n \"recipe[database::master]\"\n ],\n \"override_attributes\": {\n }\n }\n\nCreate a `production` environment. This is also used in the\n`application` cookbook.\n\n % knife environment show production -Fj\n {\n \"name\": \"production\",\n \"description\": \"\",\n \"cookbook_versions\": {\n },\n \"json_class\": \"Chef::Environment\",\n \"chef_type\": \"environment\",\n \"default_attributes\": {\n },\n \"override_attributes\": {\n }\n }\n\n\nThe cookbook `my_app_database` is recommended to set up any\napplication specific database resources such as configuration\ntemplates, trending monitors, etc. It is not required, but you would\nneed to create it separately in `site-cookbooks`. Add it to the\n`my_app_database_master` role.\n\nLicense and Author\n==================\n\n- Author:: Adam Jacob (<adam@opscode.com>)\n- Author:: Joshua Timberman (<joshua@opscode.com>)\n- Author:: AJ Christensen (<aj@opscode.com>)\n- Author:: Seth Chisamore (<schisamo@opscode.com>)\n- Author:: Lamont Granquist (<lamont@opscode.com>)\n\nCopyright 2009-2012, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
5
+ "maintainer": "Opscode, Inc.",
6
+ "maintainer_email": "cookbooks@opscode.com",
7
+ "license": "Apache 2.0",
8
+ "platforms": {
9
+ "debian": ">= 0.0.0",
10
+ "ubuntu": ">= 0.0.0",
11
+ "centos": ">= 0.0.0",
12
+ "suse": ">= 0.0.0",
13
+ "fedora": ">= 0.0.0",
14
+ "redhat": ">= 0.0.0",
15
+ "scientific": ">= 0.0.0"
16
+ },
17
+ "dependencies": {
18
+ "mysql": ">= 1.3.0",
19
+ "postgresql": ">= 1.0.0",
20
+ "aws": ">= 0.0.0",
21
+ "xfs": ">= 0.0.0"
22
+ },
23
+ "recommendations": {
24
+ },
25
+ "suggestions": {
26
+ },
27
+ "conflicting": {
28
+ },
29
+ "providing": {
30
+ },
31
+ "replacing": {
32
+ },
33
+ "attributes": {
34
+ },
35
+ "groupings": {
36
+ },
37
+ "recipes": {
38
+ "database": "Empty placeholder",
39
+ "database::ebs_backup": "Considered deprecated, older way of backing up EBS volumes",
40
+ "database::ebs_volume": "Sets up an EBS volume in EC2 for the database",
41
+ "database::master": "Creates application specific user and database",
42
+ "database::snapshot": "Locks tables and freezes XFS filesystem for replication, assumes EC2 + EBS"
43
+ },
44
+ "version": "1.3.4"
45
+ }
@@ -0,0 +1,22 @@
1
+ name "database"
2
+ maintainer "Opscode, Inc."
3
+ maintainer_email "cookbooks@opscode.com"
4
+ license "Apache 2.0"
5
+ description "Sets up the database master or slave"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "1.3.4"
8
+
9
+ recipe "database", "Empty placeholder"
10
+ recipe "database::ebs_backup", "Considered deprecated, older way of backing up EBS volumes"
11
+ recipe "database::ebs_volume", "Sets up an EBS volume in EC2 for the database"
12
+ recipe "database::master", "Creates application specific user and database"
13
+ recipe "database::snapshot", "Locks tables and freezes XFS filesystem for replication, assumes EC2 + EBS"
14
+
15
+ depends "mysql", ">= 1.3.0"
16
+ depends "postgresql", ">= 1.0.0"
17
+ depends "aws"
18
+ depends "xfs"
19
+
20
+ %w{ debian ubuntu centos suse fedora redhat scientific }.each do |os|
21
+ supports os
22
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
3
+ # Cookbook Name:: database
4
+ # Recipe:: default
5
+ #
6
+ # Copyright 2009, 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
+
@@ -0,0 +1,89 @@
1
+ #
2
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
3
+ # Cookbook Name:: database
4
+ # Recipe:: ebs_backup
5
+ #
6
+ # Copyright 2009, 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
+
21
+ begin
22
+ aws = Chef::DataBagItem.load('aws', 'main')
23
+ Chef::Log.info("Loaded AWS information from DataBagItem aws[#{aws['id']}]")
24
+ rescue
25
+ Chef::Log.fatal("Could not find the 'main' item in the 'aws' data bag")
26
+ raise
27
+ end
28
+
29
+ db_role = String.new
30
+ db_master_role = String.new
31
+ db_type = node[:database][:type]
32
+
33
+ search(:apps) do |app|
34
+ db_role = app["database_#{db_type}_role"] & node.run_list.roles
35
+ db_master_role = app["database_master_role"]
36
+ end
37
+
38
+ ebs_info = Chef::DataBagItem.load(:aws, "ebs_#{db_master_role}_#{node.chef_environment}")
39
+
40
+ gem_package "dbi"
41
+ gem_package "dbd-mysql"
42
+
43
+ directory "/mnt/aws-config" do
44
+ mode 0700
45
+ owner "root"
46
+ group "root"
47
+ end
48
+
49
+ template "/mnt/aws-config/config" do
50
+ source "aws_config.erb"
51
+ variables(
52
+ :access_key => aws['aws_access_key_id'],
53
+ :secret_key => aws['aws_secret_access_key']
54
+ )
55
+ owner "root"
56
+ group "root"
57
+ mode 0600
58
+ end
59
+
60
+ git "/opt/ec2_mysql" do
61
+ repository "git://github.com/jtimberman/ec2_mysql.git"
62
+ reference "HEAD"
63
+ action :sync
64
+ not_if { ::FileTest.directory?("/opt/ec2_mysql/.git") }
65
+ end
66
+
67
+ %w{backup restore}.each do |file|
68
+ template "/usr/local/bin/db-#{file}.sh" do
69
+ source "ebs-db-#{file}.sh.erb"
70
+ owner "root"
71
+ group "root"
72
+ mode 0700
73
+ variables(
74
+ :mysql_root_passwd => node['mysql']['server_root_password'],
75
+ :mysql_device => node['mysql']['ebs_vol_dev'],
76
+ :ebs_vol_id => ebs_info['volume_id']
77
+ )
78
+ end
79
+ end
80
+
81
+ if db_type == "master" && node.chef_environment == "production"
82
+ template "/etc/cron.d/db-backup" do
83
+ source "ebs-backup-cron.erb"
84
+ owner "root"
85
+ group "root"
86
+ mode 0644
87
+ backup false
88
+ end
89
+ end