1 |
class apache { |
2 |
|
3 |
class base { |
4 |
$php_date_timezone = "UTC" |
5 |
|
6 |
package { "apache-mpm-prefork": |
7 |
alias => apache, |
8 |
ensure => installed |
9 |
} |
10 |
|
11 |
package { "apache-conf": |
12 |
ensure => installed, |
13 |
} |
14 |
|
15 |
service { httpd: |
16 |
alias => apache, |
17 |
ensure => running, |
18 |
subscribe => [ Package['apache-mpm-prefork'] ], |
19 |
} |
20 |
|
21 |
file { "customization.conf": |
22 |
ensure => present, |
23 |
path => "/etc/httpd/conf.d/customization.conf", |
24 |
content => template("apache/customization.conf"), |
25 |
require => Package["apache-conf"], |
26 |
notify => Service["apache"], |
27 |
owner => root, |
28 |
group => root, |
29 |
mode => 644, |
30 |
} |
31 |
|
32 |
file { "00_default_vhosts.conf": |
33 |
path => "/etc/httpd/conf/vhosts.d/00_default_vhosts.conf", |
34 |
ensure => "present", |
35 |
owner => root, |
36 |
group => root, |
37 |
mode => 644, |
38 |
notify => Service['apache'], |
39 |
require => Package["apache-conf"], |
40 |
content => template("apache/00_default_vhosts.conf") |
41 |
} |
42 |
|
43 |
} |
44 |
|
45 |
class mod_php inherits base { |
46 |
include php::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 |
$enable_public_html = false) { |
150 |
include apache::base |
151 |
if ! $vhost { |
152 |
$real_vhost = $name |
153 |
} else { |
154 |
$real_vhost = $vhost |
155 |
} |
156 |
|
157 |
if $use_ssl { |
158 |
include apache::mod_ssl |
159 |
if $wildcard_sslcert != 'true' { |
160 |
openssl::self_signed_cert{ "$real_vhost": |
161 |
directory => "/etc/ssl/apache/", |
162 |
before => File["$filename"], |
163 |
} |
164 |
} |
165 |
} |
166 |
|
167 |
if $enable_public_html { |
168 |
include apache::mod_public_html |
169 |
} |
170 |
|
171 |
$filename = "$name.conf" |
172 |
file { "$filename": |
173 |
path => "/etc/httpd/conf/vhosts.d/$filename", |
174 |
ensure => "present", |
175 |
owner => root, |
176 |
group => root, |
177 |
mode => 644, |
178 |
notify => Service['apache'], |
179 |
require => Package['apache-conf'], |
180 |
content => template("apache/vhost_base.conf") |
181 |
} |
182 |
} |
183 |
|
184 |
define vhost_redirect_ssl() { |
185 |
vhost_base { "redirect_ssl_$name": |
186 |
vhost => $name, |
187 |
content => template("apache/vhost_ssl_redirect.conf") |
188 |
} |
189 |
} |
190 |
|
191 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { |
192 |
|
193 |
include apache::mod_fastcgi |
194 |
vhost_base { $name: |
195 |
use_ssl => $use_ssl, |
196 |
content => template("apache/vhost_catalyst_app.conf") |
197 |
} |
198 |
} |
199 |
|
200 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) { |
201 |
include apache::mod_wsgi |
202 |
vhost_base { $name: |
203 |
use_ssl => $use_ssl, |
204 |
content => template("apache/vhost_django_app.conf"), |
205 |
aliases => $aliases, |
206 |
} |
207 |
|
208 |
# module is a ruby reserved keyword, cannot be used in templates |
209 |
$django_module = $module |
210 |
file { "$name.wsgi": |
211 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
212 |
ensure => "present", |
213 |
owner => root, |
214 |
group => root, |
215 |
mode => 755, |
216 |
notify => Service['apache'], |
217 |
content => template("apache/django.wsgi") |
218 |
} |
219 |
} |
220 |
|
221 |
define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) { |
222 |
include apache::mod_wsgi |
223 |
vhost_base { $name: |
224 |
aliases => $aliases, |
225 |
server_aliases => $server_aliases, |
226 |
content => template("apache/vhost_wsgi.conf") |
227 |
} |
228 |
} |
229 |
|
230 |
define vhost_other_app($vhost_file) { |
231 |
include apache::base |
232 |
file { "$name.conf": |
233 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
234 |
ensure => "present", |
235 |
owner => root, |
236 |
group => root, |
237 |
mode => 644, |
238 |
notify => Service['apache'], |
239 |
require => Package['apache-conf'], |
240 |
content => template($vhost_file) |
241 |
} |
242 |
} |
243 |
|
244 |
define vhost_simple($location) { |
245 |
include apache::base |
246 |
vhost_base { $name: |
247 |
location => $location, |
248 |
} |
249 |
} |
250 |
|
251 |
define vhost_redirect($url, |
252 |
$vhost = false, |
253 |
$use_ssl = false) { |
254 |
include apache::base |
255 |
vhost_base { $name: |
256 |
use_ssl => $use_ssl, |
257 |
vhost => $vhost, |
258 |
content => template("apache/vhost_redirect.conf"), |
259 |
} |
260 |
} |
261 |
|
262 |
define vhost_reverse_proxy($url, |
263 |
$vhost = false, |
264 |
$use_ssl = false) { |
265 |
include apache::mod_proxy |
266 |
vhost_base { $name: |
267 |
use_ssl => $use_ssl, |
268 |
vhost => $vhost, |
269 |
content => template("apache/vhost_reverse_proxy.conf") |
270 |
} |
271 |
} |
272 |
|
273 |
define webapp_other($webapp_file) { |
274 |
include apache::base |
275 |
$webappname = $name |
276 |
file { "webapp_$name.conf": |
277 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
278 |
ensure => "present", |
279 |
owner => root, |
280 |
group => root, |
281 |
mode => 644, |
282 |
notify => Service['apache'], |
283 |
require => Package['apache-conf'], |
284 |
content => template($webapp_file) |
285 |
} |
286 |
} |
287 |
} |