1 |
class apache { |
2 |
|
3 |
class base { |
4 |
package { "apache-mpm-prefork": |
5 |
alias => apache, |
6 |
ensure => installed |
7 |
} |
8 |
|
9 |
package { "apache-conf": |
10 |
ensure => installed, |
11 |
} |
12 |
|
13 |
service { httpd: |
14 |
alias => apache, |
15 |
ensure => running, |
16 |
subscribe => [ Package['apache-mpm-prefork'] ], |
17 |
} |
18 |
|
19 |
file { "customization.conf": |
20 |
ensure => present, |
21 |
path => "/etc/httpd/conf.d/customization.conf", |
22 |
content => template("apache/customization.conf"), |
23 |
require => Package["apache-conf"], |
24 |
notify => Service["apache"], |
25 |
owner => root, |
26 |
group => root, |
27 |
mode => 644, |
28 |
} |
29 |
|
30 |
file { "00_default_vhosts.conf": |
31 |
path => "/etc/httpd/conf/vhosts.d/00_default_vhosts.conf", |
32 |
ensure => "present", |
33 |
owner => root, |
34 |
group => root, |
35 |
mode => 644, |
36 |
notify => Service['apache'], |
37 |
require => Package["apache-conf"], |
38 |
content => template("apache/00_default_vhosts.conf") |
39 |
} |
40 |
|
41 |
} |
42 |
|
43 |
class mod_php inherits base { |
44 |
include php::base |
45 |
package { "apache-mod_php": |
46 |
ensure => installed |
47 |
} |
48 |
|
49 |
file { "/etc/httpd/conf.d/mod_php.conf": |
50 |
ensure => present, |
51 |
owner => root, |
52 |
group => root, |
53 |
mode => 644, |
54 |
require => Package['apache-conf'], |
55 |
content => template('apache/mod_php.conf'), |
56 |
notify => Service['apache'], |
57 |
} |
58 |
} |
59 |
|
60 |
class mod_perl inherits base { |
61 |
package { "apache-mod_perl": |
62 |
ensure => installed |
63 |
} |
64 |
} |
65 |
|
66 |
class mod_fcgid inherits base { |
67 |
package { "apache-mod_fcgid": |
68 |
ensure => installed |
69 |
} |
70 |
} |
71 |
|
72 |
class mod_fastcgi inherits base { |
73 |
package { "apache-mod_fastcgi": |
74 |
ensure => installed |
75 |
} |
76 |
} |
77 |
|
78 |
class mod_ssl inherits base { |
79 |
file { "/etc/ssl/apache/": |
80 |
ensure => directory |
81 |
} |
82 |
|
83 |
package { "apache-mod_ssl": |
84 |
ensure => installed |
85 |
} |
86 |
|
87 |
file { "01_default_ssl_vhost.conf": |
88 |
path => '/etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf', |
89 |
ensure => "present", |
90 |
owner => root, |
91 |
group => root, |
92 |
mode => 644, |
93 |
notify => Service['apache'], |
94 |
require => Package["apache-conf"], |
95 |
content => template("apache/01_default_ssl_vhost.conf") |
96 |
} |
97 |
} |
98 |
|
99 |
class mod_wsgi inherits base { |
100 |
package { "apache-mod_wsgi": |
101 |
ensure => installed |
102 |
} |
103 |
|
104 |
file { "/usr/local/lib/wsgi": |
105 |
ensure => directory, |
106 |
owner => root, |
107 |
group => root, |
108 |
mode => 644, |
109 |
} |
110 |
|
111 |
file { "/etc/httpd/conf.d/mod_wsgi.conf": |
112 |
ensure => present, |
113 |
owner => root, |
114 |
group => root, |
115 |
mode => 644, |
116 |
require => Package['apache-conf'], |
117 |
content => template('apache/mod_wsgi.conf'), |
118 |
notify => Service['apache'], |
119 |
} |
120 |
|
121 |
} |
122 |
|
123 |
class mod_proxy inherits base { |
124 |
package { "apache-mod_proxy": |
125 |
ensure => installed |
126 |
} |
127 |
} |
128 |
|
129 |
class mod_public_html inherits base { |
130 |
package { "apache-mod_public_html": |
131 |
ensure => installed |
132 |
} |
133 |
} |
134 |
|
135 |
class mod_deflate inherits base { |
136 |
package { "apache-mod_deflate": |
137 |
ensure => installed |
138 |
} |
139 |
} |
140 |
|
141 |
define vhost_base($content = '', |
142 |
$location = '/dev/null', |
143 |
$use_ssl = false, |
144 |
$vhost = false, |
145 |
$aliases = {}, |
146 |
$server_aliases = [], |
147 |
$enable_public_html = false) { |
148 |
include apache::base |
149 |
if ! $vhost { |
150 |
$real_vhost = $name |
151 |
} else { |
152 |
$real_vhost = $vhost |
153 |
} |
154 |
|
155 |
if $use_ssl { |
156 |
include apache::mod_ssl |
157 |
if $wildcard_sslcert != 'true' { |
158 |
openssl::self_signed_cert{ "$real_vhost": |
159 |
directory => "/etc/ssl/apache/", |
160 |
before => File["$filename"], |
161 |
} |
162 |
} |
163 |
} |
164 |
|
165 |
if $enable_public_html { |
166 |
include apache::mod_public_html |
167 |
} |
168 |
|
169 |
$filename = "$name.conf" |
170 |
file { "$filename": |
171 |
path => "/etc/httpd/conf/vhosts.d/$filename", |
172 |
ensure => "present", |
173 |
owner => root, |
174 |
group => root, |
175 |
mode => 644, |
176 |
notify => Service['apache'], |
177 |
require => Package['apache-conf'], |
178 |
content => template("apache/vhost_base.conf") |
179 |
} |
180 |
} |
181 |
|
182 |
define vhost_redirect_ssl() { |
183 |
vhost_base { "redirect_ssl_$name": |
184 |
vhost => $name, |
185 |
content => template("apache/vhost_ssl_redirect.conf") |
186 |
} |
187 |
} |
188 |
|
189 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { |
190 |
|
191 |
include apache::mod_fastcgi |
192 |
vhost_base { $name: |
193 |
use_ssl => $use_ssl, |
194 |
content => template("apache/vhost_catalyst_app.conf") |
195 |
} |
196 |
} |
197 |
|
198 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) { |
199 |
include apache::mod_wsgi |
200 |
vhost_base { $name: |
201 |
use_ssl => $use_ssl, |
202 |
content => template("apache/vhost_django_app.conf"), |
203 |
aliases => $aliases, |
204 |
} |
205 |
|
206 |
# module is a ruby reserved keyword, cannot be used in templates |
207 |
$django_module = $module |
208 |
file { "$name.wsgi": |
209 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
210 |
ensure => "present", |
211 |
owner => root, |
212 |
group => root, |
213 |
mode => 755, |
214 |
notify => Service['apache'], |
215 |
content => template("apache/django.wsgi") |
216 |
} |
217 |
} |
218 |
|
219 |
define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) { |
220 |
include apache::mod_wsgi |
221 |
vhost_base { $name: |
222 |
aliases => $aliases, |
223 |
server_aliases => $server_aliases, |
224 |
content => template("apache/vhost_wsgi.conf") |
225 |
} |
226 |
} |
227 |
|
228 |
define vhost_other_app($vhost_file) { |
229 |
include apache::base |
230 |
file { "$name.conf": |
231 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
232 |
ensure => "present", |
233 |
owner => root, |
234 |
group => root, |
235 |
mode => 644, |
236 |
notify => Service['apache'], |
237 |
require => Package['apache-conf'], |
238 |
content => template($vhost_file) |
239 |
} |
240 |
} |
241 |
|
242 |
define vhost_simple($location) { |
243 |
include apache::base |
244 |
vhost_base { $name: |
245 |
location => $location, |
246 |
} |
247 |
} |
248 |
|
249 |
define vhost_redirect($url, |
250 |
$vhost = false, |
251 |
$use_ssl = false) { |
252 |
include apache::base |
253 |
vhost_base { $name: |
254 |
use_ssl => $use_ssl, |
255 |
vhost => $vhost, |
256 |
content => template("apache/vhost_redirect.conf"), |
257 |
} |
258 |
} |
259 |
|
260 |
define vhost_reverse_proxy($url, |
261 |
$vhost = false, |
262 |
$use_ssl = false) { |
263 |
include apache::mod_proxy |
264 |
vhost_base { $name: |
265 |
use_ssl => $use_ssl, |
266 |
vhost => $vhost, |
267 |
content => template("apache/vhost_reverse_proxy.conf") |
268 |
} |
269 |
} |
270 |
|
271 |
define webapp_other($webapp_file) { |
272 |
include apache::base |
273 |
$webappname = $name |
274 |
file { "webapp_$name.conf": |
275 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
276 |
ensure => "present", |
277 |
owner => root, |
278 |
group => root, |
279 |
mode => 644, |
280 |
notify => Service['apache'], |
281 |
require => Package['apache-conf'], |
282 |
content => template($webapp_file) |
283 |
} |
284 |
} |
285 |
} |