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