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