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