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,43 @@
1
+ #
2
+ # Cookbook Name:: apache2
3
+ # Definition:: apache_site
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
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
+ define :apache_site, :enable => true do
21
+ include_recipe "apache2"
22
+
23
+ if params[:enable]
24
+ execute "a2ensite #{params[:name]}" do
25
+ command "/usr/sbin/a2ensite #{params[:name]}"
26
+ notifies :restart, resources(:service => "apache2")
27
+ not_if do
28
+ ::File.symlink?("#{node['apache']['dir']}/sites-enabled/#{params[:name]}") or
29
+ ::File.symlink?("#{node['apache']['dir']}/sites-enabled/000-#{params[:name]}")
30
+ end
31
+ only_if do ::File.exists?("#{node['apache']['dir']}/sites-available/#{params[:name]}") end
32
+ end
33
+ else
34
+ execute "a2dissite #{params[:name]}" do
35
+ command "/usr/sbin/a2dissite #{params[:name]}"
36
+ notifies :restart, resources(:service => "apache2")
37
+ only_if do
38
+ ::File.symlink?("#{node['apache']['dir']}/sites-enabled/#{params[:name]}") or
39
+ ::File.symlink?("#{node['apache']['dir']}/sites-enabled/000-#{params[:name]}")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Cookbook Name:: apache2
3
+ # Definition:: web_app
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
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
+ define :web_app, :template => "web_app.conf.erb", :enable => true do
21
+
22
+ application_name = params[:name]
23
+
24
+ include_recipe "apache2"
25
+ include_recipe "apache2::mod_rewrite"
26
+ include_recipe "apache2::mod_deflate"
27
+ include_recipe "apache2::mod_headers"
28
+
29
+ template "#{node['apache']['dir']}/sites-available/#{application_name}.conf" do
30
+ source params[:template]
31
+ owner "root"
32
+ group node['apache']['root_group']
33
+ mode 0644
34
+ if params[:cookbook]
35
+ cookbook params[:cookbook]
36
+ end
37
+ variables(
38
+ :application_name => application_name,
39
+ :params => params
40
+ )
41
+ if ::File.exists?("#{node['apache']['dir']}/sites-enabled/#{application_name}.conf")
42
+ notifies :reload, resources(:service => "apache2"), :delayed
43
+ end
44
+ end
45
+
46
+ apache_site "#{params[:name]}.conf" do
47
+ enable params[:enable]
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/perl
2
+
3
+ =begin
4
+
5
+ Generates Ubuntu style module.load files.
6
+
7
+ ./apache2_module_conf_generate.pl /usr/lib64/httpd/modules /etc/httpd/mods-available
8
+
9
+ ARGV[0] is the apache modules directory, ARGV[1] is where you want 'em.
10
+
11
+ =cut
12
+
13
+ use File::Find;
14
+
15
+ use strict;
16
+ use warnings;
17
+
18
+ die "Must have '/path/to/modules' and '/path/to/modules.load'"
19
+ unless $ARGV[0] && $ARGV[1];
20
+
21
+ find(
22
+ {
23
+ wanted => sub {
24
+ return 1 if $File::Find::name !~ /\.so$/;
25
+ my $modfile = $_;
26
+ $modfile =~ /(lib|mod_)(.+)\.so$/;
27
+ my $modname = $2;
28
+ my $filename = "$ARGV[1]/$modname.load";
29
+ unless ( -f $filename ) {
30
+ open( FILE, ">", $filename ) or die "Cannot open $filename";
31
+ print FILE "LoadModule " . $modname . "_module $File::Find::name\n";
32
+ close(FILE);
33
+ }
34
+ },
35
+ follow => 1,
36
+ },
37
+ $ARGV[0]
38
+ );
39
+
40
+ exit 0;
41
+
@@ -0,0 +1,64 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::default' do
4
+ include Helpers::Apache
5
+ it 'installs apache' do
6
+ package(node['apache']['package']).must_be_installed
7
+ end
8
+ it 'starts apache' do
9
+ apache_service.must_be_running
10
+ end
11
+ it 'enables apache' do
12
+ apache_service.must_be_enabled
13
+ end
14
+ it 'creates the conf.d directory' do
15
+ directory("#{node['apache']['dir']}/conf.d").must_exist.with(:mode, "755")
16
+ end
17
+ it 'creates the logs directory' do
18
+ directory(node['apache']['log_dir']).must_exist
19
+ end
20
+ it 'enables the default site' do
21
+ file("#{node['apache']['dir']}/sites-enabled/000-default").must_exist
22
+ file("#{node['apache']['dir']}/sites-available/default").must_exist
23
+ end
24
+ it 'ensures the debian-style apache module scripts are present' do
25
+ %w{a2ensite a2dissite a2enmod a2dismod}.each do |mod_script|
26
+ file("/usr/sbin/#{mod_script}").must_exist
27
+ end
28
+ end
29
+ it 'reports server name only, not detailed version info' do
30
+ assert_match(/^ServerTokens Prod *$/, File.read("#{node['apache']['dir']}/conf.d/security"))
31
+ end
32
+ it 'listens on port 80' do
33
+ apache_configured_ports.must_include(80)
34
+ end
35
+ it 'only listens on port 443 when SSL is enabled' do
36
+ unless ran_recipe?('apache2::mod_ssl')
37
+ apache_configured_ports.wont_include(443)
38
+ end
39
+ end
40
+ it 'reports server name only, not detailed version info' do
41
+ file("#{node['apache']['dir']}/conf.d/security").must_match(/^ServerTokens Prod *$/)
42
+ end
43
+ it 'listens on port 80' do
44
+ apache_configured_ports.must_include(80)
45
+ end
46
+ it 'only listens on port 443 when SSL is enabled' do
47
+ unless ran_recipe?('apache2::mod_ssl')
48
+ apache_configured_ports.wont_include(443)
49
+ end
50
+ end
51
+ describe 'centos' do
52
+ it 'ensures no modules are loaded in conf.d' do
53
+ Dir["#{node['apache']['dir']}/conf.d/*"].each do |f|
54
+ file(f).wont_include 'LoadModule'
55
+ end
56
+ end
57
+ end
58
+ describe 'configuration' do
59
+ it { config.must_include '# Generated by Chef' }
60
+ it { config.must_include %Q{ServerRoot "#{node['apache']['dir']}"} }
61
+ it { config.must_include "Include #{node['apache']['dir']}/conf.d/" }
62
+ it { apache_config_parses? }
63
+ end
64
+ end
@@ -0,0 +1,36 @@
1
+ module Helpers
2
+ module Apache
3
+ include MiniTest::Chef::Assertions
4
+ include MiniTest::Chef::Context
5
+ include MiniTest::Chef::Resources
6
+
7
+ def apache_config_parses?
8
+ %x{#{node['apache']['binary']} -t}
9
+ $?.success?
10
+ end
11
+ def apache_configured_ports
12
+ port_config = File.read("#{node['apache']['dir']}/ports.conf")
13
+ port_config.scan(/^Listen ([0-9]+)/).flatten.map{|p| p.to_i}
14
+ end
15
+ def apache_enabled_modules
16
+ Dir["#{node['apache']['dir']}/mods-enabled/*.load"].map{|s| File.basename(s, '.load')}.sort
17
+ end
18
+ def apache_service
19
+ service(case node['platform']
20
+ when "debian","ubuntu" then "apache2"
21
+ when "freebsd" then "apache22"
22
+ else "httpd"
23
+ end)
24
+ end
25
+ def config
26
+ file(case node['platform']
27
+ when "debian","ubuntu" then "#{node['apache']['dir']}/apache2.conf"
28
+ when "freebsd" then "#{node['apache']['dir']}/httpd.conf"
29
+ else "#{node['apache']['dir']}/conf/httpd.conf"
30
+ end)
31
+ end
32
+ def ran_recipe?(recipe)
33
+ node.run_state[:seen_recipes].keys.include?(recipe)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+ require 'pathname'
3
+
4
+ describe 'apache2::mod_auth_openid' do
5
+ include Helpers::Apache
6
+
7
+ it "installs the opekele library" do
8
+ lib_dir = Pathname.new(node['apache']['lib_dir']).dirname.to_s
9
+ file("#{lib_dir}/libopkele.so").must_exist
10
+ end
11
+
12
+ it "does not add the module to httpd.conf" do
13
+ httpd_config = File.read("#{node['apache']['dir']}/conf/httpd.conf")
14
+ refute_match /^LoadModule authopenid_module /, httpd_config
15
+ end
16
+
17
+ it "creates a cache directory for the module" do
18
+ directory(node['apache']['mod_auth_openid']['cache_dir']).must_exist.with(:owner, node['apache']['user'])
19
+ end
20
+
21
+ it "ensures the db file is writable by apache" do
22
+ file(node['apache']['mod_auth_openid']['dblocation']).must_exist.with(:owner, node['apache']['user']).and(:mode, "644")
23
+ end
24
+
25
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_dav_svn' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs mod_dav_svn' do
7
+ mod_dav_svn = case node['platform']
8
+ when "centos","redhat","scientific","fedora","suse","amazon"
9
+ "mod_dav_svn"
10
+ else
11
+ "libapache2-svn"
12
+ end
13
+ package(mod_dav_svn).must_be_installed
14
+ end
15
+
16
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_perl' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs mod_perl' do
7
+ mod_perl_pkg = case node['platform']
8
+ when 'debian', 'ubuntu' then 'libapache2-mod-perl2'
9
+ else 'mod_perl'
10
+ end
11
+ package(mod_perl_pkg).must_be_installed
12
+ end
13
+
14
+ it 'installs the apache request library' do
15
+ req_pkg = case node['platform']
16
+ when 'debian', 'ubuntu' then 'libapache2-request-perl'
17
+ else 'perl-libapreq2'
18
+ end
19
+ package(req_pkg).must_be_installed
20
+ end
21
+
22
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_php5' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs mod_php5' do
7
+ mod_php_pkg = case node['platform']
8
+ when 'debian', 'ubuntu' then 'libapache2-mod-php5'
9
+ else 'php53'
10
+ end
11
+ package(mod_php_pkg).must_be_installed
12
+ end
13
+
14
+ it "deletes the stock php config on rhel distributions" do
15
+ skip unless node.platform?("amazon", "redhat", "centos", "scientific")
16
+ file("#{node['apache']['dir']}/conf.d/php.conf").wont_exist
17
+ end
18
+
19
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_python' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs mod_python' do
7
+ mod_python_pkg = case node['platform']
8
+ when 'debian', 'ubuntu' then 'libapache2-mod-python'
9
+ else 'mod_python'
10
+ end
11
+ package(mod_python_pkg).must_be_installed
12
+ end
13
+
14
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_ssl' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs the mod_ssl package on RHEL distributions' do
7
+ skip unless ["redhat", "centos", "scientific", "fedora", "amazon"].include? node.platform
8
+ package("mod_ssl").must_be_installed
9
+ end
10
+
11
+ it 'does not store SSL config in conf.d' do
12
+ file("#{node['apache']['dir']}/conf.d/ssl.conf").wont_exist
13
+ end
14
+
15
+ it "is configured to listen on port 443" do
16
+ apache_configured_ports.must_include(443)
17
+ end
18
+
19
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_wsgi' do
4
+ include Helpers::Apache
5
+
6
+ it "installs mod_wsgi" do
7
+ wsgi_pkg = package(case node['platform']
8
+ when "debian","ubuntu" then "libapache2-mod-wsgi"
9
+ else "mod_wsgi"
10
+ end)
11
+ wsgi_pkg.must_be_installed
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ describe 'apache2::mod_xsendfile' do
4
+ include Helpers::Apache
5
+
6
+ it "installs mod_xsendfile" do
7
+ sendfile_pkg = package(case node['platform']
8
+ when "debian","ubuntu" then "libapache2-mod-xsendfile"
9
+ else "mod_xsendfile"
10
+ end)
11
+ sendfile_pkg.must_be_installed
12
+ end
13
+
14
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../helpers', __FILE__)
2
+
3
+ # Many of the apache2 cookbook recipes do nothing more than install the module
4
+ # of the same name. Assert that any included recipe that claims to install a
5
+ # module actually does so.
6
+ %w{
7
+ alias apreq2 auth_basic auth_digest authn_file authnz_ldap authopenid
8
+ authz_default authz_groupfile authz_host authz_user autoindex cgi dav_fs dav
9
+ dav_svn deflate dir env expires fcgid headers ldap log_config mime
10
+ negotiation perl php5 proxy_ajp proxy_balancer proxy_connect proxy_http
11
+ proxy python rewrite setenvif ssl status wsgi xsendfile
12
+ }.each do |expected_module|
13
+ describe "apache2::mod_#{expected_module}" do
14
+ include Helpers::Apache
15
+ it "installs mod_#{expected_module}" do
16
+ apache_enabled_modules.must_include expected_module
17
+ end
18
+ end
19
+ end