vagrant-managed-servers 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. data/.gitignore +17 -0
  2. data/Berksfile +4 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +14 -0
  5. data/LICENSE +8 -0
  6. data/README.md +142 -0
  7. data/Rakefile +21 -0
  8. data/Vagrantfile +44 -0
  9. data/cookbooks/apache2/CHANGELOG.md +95 -0
  10. data/cookbooks/apache2/CONTRIBUTING.md +257 -0
  11. data/cookbooks/apache2/Gemfile +10 -0
  12. data/cookbooks/apache2/LICENSE +201 -0
  13. data/cookbooks/apache2/README.md +567 -0
  14. data/cookbooks/apache2/attributes/default.rb +149 -0
  15. data/cookbooks/apache2/attributes/mod_auth_cas.rb +2 -0
  16. data/cookbooks/apache2/attributes/mod_auth_openid.rb +32 -0
  17. data/cookbooks/apache2/definitions/apache_conf.rb +26 -0
  18. data/cookbooks/apache2/definitions/apache_module.rb +53 -0
  19. data/cookbooks/apache2/definitions/apache_site.rb +43 -0
  20. data/cookbooks/apache2/definitions/web_app.rb +49 -0
  21. data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl +41 -0
  22. data/cookbooks/apache2/files/default/tests/minitest/default_test.rb +77 -0
  23. data/cookbooks/apache2/files/default/tests/minitest/god_monitor_test.rb +34 -0
  24. data/cookbooks/apache2/files/default/tests/minitest/mod_apreq2_test.rb +19 -0
  25. data/cookbooks/apache2/files/default/tests/minitest/mod_auth_cas_test.rb +11 -0
  26. data/cookbooks/apache2/files/default/tests/minitest/mod_auth_openid_test.rb +37 -0
  27. data/cookbooks/apache2/files/default/tests/minitest/mod_cgi_test.rb +13 -0
  28. data/cookbooks/apache2/files/default/tests/minitest/mod_dav_svn_test.rb +14 -0
  29. data/cookbooks/apache2/files/default/tests/minitest/mod_fastcgi.rb +11 -0
  30. data/cookbooks/apache2/files/default/tests/minitest/mod_perl_test.rb +18 -0
  31. data/cookbooks/apache2/files/default/tests/minitest/mod_php5_test.rb +13 -0
  32. data/cookbooks/apache2/files/default/tests/minitest/mod_python_test.rb +10 -0
  33. data/cookbooks/apache2/files/default/tests/minitest/mod_ssl_test.rb +23 -0
  34. data/cookbooks/apache2/files/default/tests/minitest/support/helpers.rb +50 -0
  35. data/cookbooks/apache2/metadata.json +513 -0
  36. data/cookbooks/apache2/metadata.rb +207 -0
  37. data/cookbooks/apache2/recipes/default.rb +208 -0
  38. data/cookbooks/apache2/recipes/god_monitor.rb +33 -0
  39. data/cookbooks/apache2/recipes/logrotate.rb +29 -0
  40. data/cookbooks/apache2/recipes/mod_alias.rb +22 -0
  41. data/cookbooks/apache2/recipes/mod_apreq2.rb +54 -0
  42. data/cookbooks/apache2/recipes/mod_auth_basic.rb +20 -0
  43. data/cookbooks/apache2/recipes/mod_auth_cas.rb +59 -0
  44. data/cookbooks/apache2/recipes/mod_auth_digest.rb +20 -0
  45. data/cookbooks/apache2/recipes/mod_auth_openid.rb +111 -0
  46. data/cookbooks/apache2/recipes/mod_authn_file.rb +20 -0
  47. data/cookbooks/apache2/recipes/mod_authnz_ldap.rb +20 -0
  48. data/cookbooks/apache2/recipes/mod_authz_default.rb +20 -0
  49. data/cookbooks/apache2/recipes/mod_authz_groupfile.rb +20 -0
  50. data/cookbooks/apache2/recipes/mod_authz_host.rb +20 -0
  51. data/cookbooks/apache2/recipes/mod_authz_user.rb +20 -0
  52. data/cookbooks/apache2/recipes/mod_autoindex.rb +22 -0
  53. data/cookbooks/apache2/recipes/mod_cgi.rb +20 -0
  54. data/cookbooks/apache2/recipes/mod_dav.rb +20 -0
  55. data/cookbooks/apache2/recipes/mod_dav_fs.rb +21 -0
  56. data/cookbooks/apache2/recipes/mod_dav_svn.rb +41 -0
  57. data/cookbooks/apache2/recipes/mod_deflate.rb +22 -0
  58. data/cookbooks/apache2/recipes/mod_dir.rb +22 -0
  59. data/cookbooks/apache2/recipes/mod_env.rb +20 -0
  60. data/cookbooks/apache2/recipes/mod_expires.rb +20 -0
  61. data/cookbooks/apache2/recipes/mod_fastcgi.rb +26 -0
  62. data/cookbooks/apache2/recipes/mod_fcgid.rb +55 -0
  63. data/cookbooks/apache2/recipes/mod_headers.rb +20 -0
  64. data/cookbooks/apache2/recipes/mod_include.rb +20 -0
  65. data/cookbooks/apache2/recipes/mod_ldap.rb +20 -0
  66. data/cookbooks/apache2/recipes/mod_log_config.rb +24 -0
  67. data/cookbooks/apache2/recipes/mod_logio.rb +24 -0
  68. data/cookbooks/apache2/recipes/mod_mime.rb +22 -0
  69. data/cookbooks/apache2/recipes/mod_negotiation.rb +22 -0
  70. data/cookbooks/apache2/recipes/mod_perl.rb +44 -0
  71. data/cookbooks/apache2/recipes/mod_php5.rb +77 -0
  72. data/cookbooks/apache2/recipes/mod_proxy.rb +22 -0
  73. data/cookbooks/apache2/recipes/mod_proxy_ajp.rb +21 -0
  74. data/cookbooks/apache2/recipes/mod_proxy_balancer.rb +20 -0
  75. data/cookbooks/apache2/recipes/mod_proxy_connect.rb +20 -0
  76. data/cookbooks/apache2/recipes/mod_proxy_http.rb +20 -0
  77. data/cookbooks/apache2/recipes/mod_python.rb +38 -0
  78. data/cookbooks/apache2/recipes/mod_rewrite.rb +20 -0
  79. data/cookbooks/apache2/recipes/mod_setenvif.rb +22 -0
  80. data/cookbooks/apache2/recipes/mod_ssl.rb +46 -0
  81. data/cookbooks/apache2/recipes/mod_status.rb +22 -0
  82. data/cookbooks/apache2/recipes/mod_wsgi.rb +38 -0
  83. data/cookbooks/apache2/recipes/mod_xsendfile.rb +38 -0
  84. data/cookbooks/apache2/templates/default/a2dismod.erb +22 -0
  85. data/cookbooks/apache2/templates/default/a2dissite.erb +29 -0
  86. data/cookbooks/apache2/templates/default/a2enmod.erb +37 -0
  87. data/cookbooks/apache2/templates/default/a2ensite.erb +38 -0
  88. data/cookbooks/apache2/templates/default/apache2.conf.erb +237 -0
  89. data/cookbooks/apache2/templates/default/apache2.god.erb +19 -0
  90. data/cookbooks/apache2/templates/default/charset.erb +6 -0
  91. data/cookbooks/apache2/templates/default/default-site.erb +57 -0
  92. data/cookbooks/apache2/templates/default/mods/README +2 -0
  93. data/cookbooks/apache2/templates/default/mods/alias.conf.erb +24 -0
  94. data/cookbooks/apache2/templates/default/mods/auth_cas.conf.erb +1 -0
  95. data/cookbooks/apache2/templates/default/mods/auth_cas.load.erb +1 -0
  96. data/cookbooks/apache2/templates/default/mods/authopenid.load.erb +1 -0
  97. data/cookbooks/apache2/templates/default/mods/autoindex.conf.erb +101 -0
  98. data/cookbooks/apache2/templates/default/mods/deflate.conf.erb +16 -0
  99. data/cookbooks/apache2/templates/default/mods/dir.conf.erb +5 -0
  100. data/cookbooks/apache2/templates/default/mods/fastcgi.conf.erb +5 -0
  101. data/cookbooks/apache2/templates/default/mods/fcgid.conf.erb +10 -0
  102. data/cookbooks/apache2/templates/default/mods/mime.conf.erb +198 -0
  103. data/cookbooks/apache2/templates/default/mods/negotiation.conf.erb +18 -0
  104. data/cookbooks/apache2/templates/default/mods/php5.conf.erb +16 -0
  105. data/cookbooks/apache2/templates/default/mods/proxy.conf.erb +19 -0
  106. data/cookbooks/apache2/templates/default/mods/setenvif.conf.erb +28 -0
  107. data/cookbooks/apache2/templates/default/mods/ssl.conf.erb +76 -0
  108. data/cookbooks/apache2/templates/default/mods/status.conf.erb +26 -0
  109. data/cookbooks/apache2/templates/default/port_apache.erb +2 -0
  110. data/cookbooks/apache2/templates/default/ports.conf.erb +6 -0
  111. data/cookbooks/apache2/templates/default/security.erb +50 -0
  112. data/cookbooks/apache2/templates/default/web_app.conf.erb +43 -0
  113. data/cookbooks/apt/Berksfile +8 -0
  114. data/cookbooks/apt/CHANGELOG.md +97 -0
  115. data/cookbooks/apt/CONTRIBUTING +29 -0
  116. data/cookbooks/apt/LICENSE +201 -0
  117. data/cookbooks/apt/README.md +243 -0
  118. data/cookbooks/apt/TESTING.md +25 -0
  119. data/cookbooks/apt/attributes/default.rb +4 -0
  120. data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  121. data/cookbooks/apt/metadata.json +1 -0
  122. data/cookbooks/apt/metadata.rb +30 -0
  123. data/cookbooks/apt/providers/preference.rb +61 -0
  124. data/cookbooks/apt/providers/repository.rb +132 -0
  125. data/cookbooks/apt/recipes/cacher-client.rb +59 -0
  126. data/cookbooks/apt/recipes/cacher-ng.rb +40 -0
  127. data/cookbooks/apt/recipes/default.rb +68 -0
  128. data/cookbooks/apt/resources/preference.rb +30 -0
  129. data/cookbooks/apt/resources/repository.rb +40 -0
  130. data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +174 -0
  131. data/cookbooks/apt/templates/default/01proxy.erb +2 -0
  132. data/cookbooks/apt/templates/default/acng.conf.erb +276 -0
  133. data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +270 -0
  134. data/dummy.box +0 -0
  135. data/lib/vagrant-managed-servers.rb +18 -0
  136. data/lib/vagrant-managed-servers/action.rb +114 -0
  137. data/lib/vagrant-managed-servers/action/is_created.rb +18 -0
  138. data/lib/vagrant-managed-servers/action/is_reachable.rb +18 -0
  139. data/lib/vagrant-managed-servers/action/link_server.rb +31 -0
  140. data/lib/vagrant-managed-servers/action/message_not_reachable.rb +16 -0
  141. data/lib/vagrant-managed-servers/action/read_state.rb +84 -0
  142. data/lib/vagrant-managed-servers/action/sync_folders.rb +85 -0
  143. data/lib/vagrant-managed-servers/action/unlink_server.rb +30 -0
  144. data/lib/vagrant-managed-servers/action/warn_networks.rb +19 -0
  145. data/lib/vagrant-managed-servers/config.rb +28 -0
  146. data/lib/vagrant-managed-servers/errors.rb +19 -0
  147. data/lib/vagrant-managed-servers/plugin.rb +72 -0
  148. data/lib/vagrant-managed-servers/provider.rb +51 -0
  149. data/lib/vagrant-managed-servers/util/timer.rb +17 -0
  150. data/lib/vagrant-managed-servers/version.rb +5 -0
  151. data/locales/en.yml +45 -0
  152. data/spec/vagrant-managed-servers/config_spec.rb +28 -0
  153. data/vagrant-managed-servers.gemspec +56 -0
  154. metadata +264 -0
@@ -0,0 +1,149 @@
1
+ #
2
+ # Cookbook Name:: apache2
3
+ # Attributes:: apache
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
+ set['apache']['root_group'] = "root"
21
+
22
+ # Where the various parts of apache are
23
+ case platform
24
+ when "redhat","centos","scientific","fedora","suse","amazon"
25
+ set['apache']['package'] = "httpd"
26
+ set['apache']['dir'] = "/etc/httpd"
27
+ set['apache']['log_dir'] = "/var/log/httpd"
28
+ set['apache']['error_log'] = "error.log"
29
+ set['apache']['user'] = "apache"
30
+ set['apache']['group'] = "apache"
31
+ set['apache']['binary'] = "/usr/sbin/httpd"
32
+ set['apache']['icondir'] = "/var/www/icons"
33
+ set['apache']['cache_dir'] = "/var/cache/httpd"
34
+ if node['platform_version'].to_f >= 6 then
35
+ set['apache']['pid_file'] = "/var/run/httpd/httpd.pid"
36
+ else
37
+ set['apache']['pid_file'] = "/var/run/httpd.pid"
38
+ end
39
+ set['apache']['lib_dir'] = node['kernel']['machine'] =~ /^i[36']86$/ ? "/usr/lib/httpd" : "/usr/lib64/httpd"
40
+ set['apache']['libexecdir'] = "#{set['apache']['lib_dir']}/modules"
41
+ set['apache']['default_site_enabled'] = true
42
+ when "debian","ubuntu"
43
+ set['apache']['package'] = "apache2"
44
+ set['apache']['dir'] = "/etc/apache2"
45
+ set['apache']['log_dir'] = "/var/log/apache2"
46
+ set['apache']['error_log'] = "error.log"
47
+ set['apache']['user'] = "www-data"
48
+ set['apache']['group'] = "www-data"
49
+ set['apache']['binary'] = "/usr/sbin/apache2"
50
+ set['apache']['icondir'] = "/usr/share/apache2/icons"
51
+ set['apache']['cache_dir'] = "/var/cache/apache2"
52
+ set['apache']['pid_file'] = "/var/run/apache2.pid"
53
+ set['apache']['lib_dir'] = "/usr/lib/apache2"
54
+ set['apache']['libexecdir'] = "#{set['apache']['lib_dir']}/modules"
55
+ set['apache']['default_site_enabled'] = false
56
+ when "arch"
57
+ set['apache']['package'] = "apache"
58
+ set['apache']['dir'] = "/etc/httpd"
59
+ set['apache']['log_dir'] = "/var/log/httpd"
60
+ set['apache']['error_log'] = "error.log"
61
+ set['apache']['user'] = "http"
62
+ set['apache']['group'] = "http"
63
+ set['apache']['binary'] = "/usr/sbin/httpd"
64
+ set['apache']['icondir'] = "/usr/share/httpd/icons"
65
+ set['apache']['cache_dir'] = "/var/cache/httpd"
66
+ set['apache']['pid_file'] = "/var/run/httpd/httpd.pid"
67
+ set['apache']['lib_dir'] = "/usr/lib/httpd"
68
+ set['apache']['libexecdir'] = "#{set['apache']['lib_dir']}/modules"
69
+ set['apache']['default_site_enabled'] = false
70
+ when "freebsd"
71
+ set['apache']['package'] = "apache22"
72
+ set['apache']['dir'] = "/usr/local/etc/apache22"
73
+ set['apache']['log_dir'] = "/var/log"
74
+ set['apache']['error_log'] = "httpd-error.log"
75
+ set['apache']['root_group'] = "wheel"
76
+ set['apache']['user'] = "www"
77
+ set['apache']['group'] = "www"
78
+ set['apache']['binary'] = "/usr/local/sbin/httpd"
79
+ set['apache']['icondir'] = "/usr/local/www/apache22/icons"
80
+ set['apache']['cache_dir'] = "/var/run/apache22"
81
+ set['apache']['pid_file'] = "/var/run/httpd.pid"
82
+ set['apache']['lib_dir'] = "/usr/local/libexec/apache22"
83
+ set['apache']['libexecdir'] = set['apache']['lib_dir']
84
+ set['apache']['default_site_enabled'] = false
85
+ else
86
+ set['apache']['dir'] = "/etc/apache2"
87
+ set['apache']['log_dir'] = "/var/log/apache2"
88
+ set['apache']['error_log'] = "error.log"
89
+ set['apache']['user'] = "www-data"
90
+ set['apache']['group'] = "www-data"
91
+ set['apache']['binary'] = "/usr/sbin/apache2"
92
+ set['apache']['icondir'] = "/usr/share/apache2/icons"
93
+ set['apache']['cache_dir'] = "/var/cache/apache2"
94
+ set['apache']['pid_file'] = "logs/httpd.pid"
95
+ set['apache']['lib_dir'] = "/usr/lib/apache2"
96
+ set['apache']['libexecdir'] = "#{set['apache']['lib_dir']}/modules"
97
+ set['apache']['default_site_enabled'] = false
98
+ end
99
+
100
+ ###
101
+ # These settings need the unless, since we want them to be tunable,
102
+ # and we don't want to override the tunings.
103
+ ###
104
+
105
+ # General settings
106
+ default['apache']['listen_ports'] = [ "80" ]
107
+ default['apache']['contact'] = "ops@example.com"
108
+ default['apache']['timeout'] = 300
109
+ default['apache']['keepalive'] = "On"
110
+ default['apache']['keepaliverequests'] = 100
111
+ default['apache']['keepalivetimeout'] = 5
112
+
113
+ # Security
114
+ default['apache']['servertokens'] = "Prod"
115
+ default['apache']['serversignature'] = "On"
116
+ default['apache']['traceenable'] = "On"
117
+
118
+ # mod_auth_openids
119
+ default['apache']['allowed_openids'] = Array.new
120
+
121
+ # mod_status ExtendedStatus, set to 'true' to enable
122
+ default['apache']['ext_status'] = false
123
+
124
+ # Prefork Attributes
125
+ default['apache']['prefork']['startservers'] = 16
126
+ default['apache']['prefork']['minspareservers'] = 16
127
+ default['apache']['prefork']['maxspareservers'] = 32
128
+ default['apache']['prefork']['serverlimit'] = 400
129
+ default['apache']['prefork']['maxclients'] = 400
130
+ default['apache']['prefork']['maxrequestsperchild'] = 10000
131
+
132
+ # Worker Attributes
133
+ default['apache']['worker']['startservers'] = 4
134
+ default['apache']['worker']['maxclients'] = 1024
135
+ default['apache']['worker']['minsparethreads'] = 64
136
+ default['apache']['worker']['maxsparethreads'] = 192
137
+ default['apache']['worker']['threadsperchild'] = 64
138
+ default['apache']['worker']['maxrequestsperchild'] = 0
139
+
140
+ # Default modules to enable via include_recipe
141
+
142
+ default['apache']['default_modules'] = %w{
143
+ status alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex
144
+ dir env mime negotiation setenvif
145
+ }
146
+
147
+ %w{ log_config logio }.each do |log_mod|
148
+ default['apache']['default_modules'] << log_mod if ["rhel", "fedora", "suse", "arch", "freebsd"].include?(node['platform_family'])
149
+ end
@@ -0,0 +1,2 @@
1
+ default['apache']['mod_auth_cas']['from_source'] = false
2
+ default['apache']['mod_auth_cas']['source_revision'] = "v1.0.8.1"
@@ -0,0 +1,32 @@
1
+ #
2
+ # Author:: Joshua Timberman <joshua@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
+ default['apache']['mod_auth_openid']['checksum'] = "79e7ca52511d1230"
20
+ default['apache']['mod_auth_openid']['version'] = "0.6"
21
+ default['apache']['mod_auth_openid']['cache_dir'] = "/var/cache/mod_auth_openid"
22
+ default['apache']['mod_auth_openid']['dblocation'] = "#{node['apache']['mod_auth_openid']['cache_dir']}/mod_auth_openid.db"
23
+
24
+ case node['platform_family']
25
+ when "freebsd"
26
+ default['apache']['mod_auth_openid']['configure_flags'] = [
27
+ "CPPFLAGS=-I/usr/local/include",
28
+ "LDFLAGS=-I/usr/local/lib -lsqlite3"
29
+ ]
30
+ else
31
+ default['apache']['mod_auth_openid']['configure_flags'] = []
32
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # Cookbook Name:: apache2
3
+ # Definition:: apache_conf
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_conf do
21
+ template "#{node['apache']['dir']}/mods-available/#{params[:name]}.conf" do
22
+ source "mods/#{params[:name]}.conf.erb"
23
+ notifies :restart, "service[apache2]"
24
+ mode 0644
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # Cookbook Name:: apache2
3
+ # Definition:: apache_module
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_module, :enable => true, :conf => false do
21
+ include_recipe "apache2"
22
+
23
+ params[:filename] = params[:filename] || "mod_#{params[:name]}.so"
24
+ params[:module_path] = params[:module_path] || "#{node['apache']['libexecdir']}/#{params[:filename]}"
25
+
26
+ if params[:conf]
27
+ apache_conf params[:name]
28
+ end
29
+
30
+ if platform_family?("rhel", "fedora", "arch", "suse", "freebsd")
31
+ file "#{node['apache']['dir']}/mods-available/#{params[:name]}.load" do
32
+ content "LoadModule #{params[:name]}_module #{params[:module_path]}\n"
33
+ mode 0644
34
+ end
35
+ end
36
+
37
+ if params[:enable]
38
+ execute "a2enmod #{params[:name]}" do
39
+ command "/usr/sbin/a2enmod #{params[:name]}"
40
+ notifies :restart, resources(:service => "apache2")
41
+ not_if do (::File.symlink?("#{node['apache']['dir']}/mods-enabled/#{params[:name]}.load") and
42
+ ((::File.exists?("#{node['apache']['dir']}/mods-available/#{params[:name]}.conf"))?
43
+ (::File.symlink?("#{node['apache']['dir']}/mods-enabled/#{params[:name]}.conf")):(true)))
44
+ end
45
+ end
46
+ else
47
+ execute "a2dismod #{params[:name]}" do
48
+ command "/usr/sbin/a2dismod #{params[:name]}"
49
+ notifies :restart, resources(:service => "apache2")
50
+ only_if do ::File.symlink?("#{node['apache']['dir']}/mods-enabled/#{params[:name]}.load") end
51
+ end
52
+ end
53
+ end
@@ -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,77 @@
1
+ require File.expand_path('../support/helpers', __FILE__)
2
+
3
+ describe 'apache2::default' do
4
+ include Helpers::Apache
5
+
6
+ it 'installs apache' do
7
+ package(node['apache']['package']).must_be_installed
8
+ end
9
+
10
+ it 'starts apache' do
11
+ apache_service.must_be_running
12
+ end
13
+
14
+ it 'enables apache' do
15
+ apache_service.must_be_enabled
16
+ end
17
+
18
+ it 'creates the conf.d directory' do
19
+ directory("#{node['apache']['dir']}/conf.d").must_exist.with(:mode, "755")
20
+ end
21
+
22
+ it 'creates the logs directory' do
23
+ directory(node['apache']['log_dir']).must_exist
24
+ end
25
+
26
+ it 'enables the default site unless it is disabled' do
27
+ skip unless node['apache']['default_site_enabled']
28
+ file("#{node['apache']['dir']}/sites-enabled/000-default").must_exist
29
+ file("#{node['apache']['dir']}/sites-available/default").must_exist
30
+ end
31
+
32
+ it 'ensures the debian-style apache module scripts are present' do
33
+ %w{a2ensite a2dissite a2enmod a2dismod}.each do |mod_script|
34
+ file("/usr/sbin/#{mod_script}").must_exist
35
+ end
36
+ end
37
+
38
+ it 'reports server name only, not detailed version info' do
39
+ assert_match(/^ServerTokens Prod *$/, File.read("#{node['apache']['dir']}/conf.d/security"))
40
+ end
41
+
42
+ it 'listens on port 80' do
43
+ apache_configured_ports.must_include(80)
44
+ end
45
+
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
+
52
+ it 'reports server name only, not detailed version info' do
53
+ file("#{node['apache']['dir']}/conf.d/security").must_match(/^ServerTokens Prod *$/)
54
+ end
55
+
56
+ it "enables default_modules" do
57
+ node['apache']['default_modules'].each do |a2mod|
58
+ apache_enabled_modules.must_include "#{a2mod}_module"
59
+ end
60
+ end
61
+
62
+ describe 'centos' do
63
+ it 'ensures no modules are loaded in conf.d' do
64
+ Dir["#{node['apache']['dir']}/conf.d/*"].each do |f|
65
+ file(f).wont_include 'LoadModule'
66
+ end
67
+ end
68
+ end
69
+
70
+ describe 'configuration' do
71
+ it { config.must_include '# Generated by Chef' }
72
+ it { config.must_include %Q{ServerRoot "#{node['apache']['dir']}"} }
73
+ it { config.must_include "Include #{node['apache']['dir']}/conf.d/" }
74
+ it { apache_config_parses? }
75
+ end
76
+
77
+ end