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