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