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