1 |
class apache { |
2 |
|
3 |
class base { |
4 |
package { "apache-mpm-prefork": |
5 |
alias => apache, |
6 |
ensure => installed |
7 |
} |
8 |
|
9 |
service { httpd: |
10 |
alias => apache, |
11 |
ensure => running, |
12 |
subscribe => [ Package['apache-mpm-prefork'] ], |
13 |
} |
14 |
|
15 |
file { "customization.conf": |
16 |
ensure => present, |
17 |
path => "/etc/httpd/conf.d/customization.conf", |
18 |
content => template("apache/customization.conf"), |
19 |
require => Package["apache"], |
20 |
notify => Service["apache"], |
21 |
owner => root, |
22 |
group => root, |
23 |
mode => 644, |
24 |
} |
25 |
|
26 |
file { "00_default_vhosts.conf": |
27 |
path => "/etc/httpd/conf/vhosts.d/00_default_vhosts.conf", |
28 |
ensure => "present", |
29 |
owner => root, |
30 |
group => root, |
31 |
mode => 644, |
32 |
notify => Service['apache'], |
33 |
content => template("apache/00_default_vhosts.conf") |
34 |
} |
35 |
} |
36 |
|
37 |
class mod_php inherits base { |
38 |
package { "apache-mod_php": |
39 |
ensure => installed |
40 |
} |
41 |
} |
42 |
|
43 |
class mod_perl inherits base { |
44 |
package { "apache-mod_perl": |
45 |
ensure => installed |
46 |
} |
47 |
} |
48 |
|
49 |
class mod_fcgid inherits base { |
50 |
package { "apache-mod_fcgid": |
51 |
ensure => installed |
52 |
} |
53 |
} |
54 |
|
55 |
class mod_fastcgi inherits base { |
56 |
package { "apache-mod_fastcgi": |
57 |
ensure => installed |
58 |
} |
59 |
} |
60 |
|
61 |
class mod_ssl inherits base { |
62 |
file { "/etc/ssl/apache/": |
63 |
ensure => directory |
64 |
} |
65 |
|
66 |
package { "apache-mod_ssl": |
67 |
ensure => installed |
68 |
} |
69 |
} |
70 |
|
71 |
class mod_wsgi inherits base { |
72 |
package { "apache-mod_wsgi": |
73 |
ensure => installed |
74 |
} |
75 |
|
76 |
file { "/usr/local/lib/wsgi": |
77 |
ensure => directory, |
78 |
owner => root, |
79 |
group => root, |
80 |
mode => 644, |
81 |
} |
82 |
|
83 |
file { "/etc/httpd/conf.d/mod_wsgi.conf": |
84 |
ensure => present, |
85 |
owner => root, |
86 |
group => root, |
87 |
mode => 644, |
88 |
content => template('apache/mod_wsgi.conf') |
89 |
} |
90 |
|
91 |
} |
92 |
|
93 |
class mod_proxy inherits base { |
94 |
package { "apache-mod_proxy": |
95 |
ensure => installed |
96 |
} |
97 |
} |
98 |
|
99 |
class mod_public_html inherits base { |
100 |
package { "apache-mod_public_html": |
101 |
ensure => installed |
102 |
} |
103 |
} |
104 |
|
105 |
define vhost_base($content = '', |
106 |
$location = '/dev/null', |
107 |
$use_ssl = false, |
108 |
$vhost = false, |
109 |
$enable_public_html = false) { |
110 |
if ! $vhost { |
111 |
$real_vhost = $name |
112 |
} else { |
113 |
$real_vhost = $vhost |
114 |
} |
115 |
|
116 |
if $use_ssl { |
117 |
include apache::mod_ssl |
118 |
openssl::self_signed_cert{ "$name": |
119 |
directory => "/etc/ssl/apache/", |
120 |
before => File["$filename"], |
121 |
} |
122 |
} |
123 |
|
124 |
if $enable_public_html { |
125 |
include apache::mod_public_html |
126 |
} |
127 |
|
128 |
$filename = "$name.conf" |
129 |
file { "$filename": |
130 |
path => "/etc/httpd/conf/vhosts.d/$filename", |
131 |
ensure => "present", |
132 |
owner => root, |
133 |
group => root, |
134 |
mode => 644, |
135 |
notify => Service['apache'], |
136 |
content => template("apache/vhost_base.conf") |
137 |
} |
138 |
} |
139 |
|
140 |
define vhost_redirect_ssl() { |
141 |
vhost_base { "redirect_ssl_$name": |
142 |
vhost => $name, |
143 |
content => template("apache/vhost_ssl_redirect.conf") |
144 |
} |
145 |
} |
146 |
|
147 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { |
148 |
|
149 |
include apache::mod_fastcgi |
150 |
vhost_base { $name: |
151 |
use_ssl => $use_ssl, |
152 |
content => template("apache/vhost_catalyst_app.conf") |
153 |
} |
154 |
} |
155 |
|
156 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false) { |
157 |
include apache::mod_wsgi |
158 |
vhost_base { $name: |
159 |
content => template("apache/vhost_django_app.conf") |
160 |
} |
161 |
|
162 |
# module is a ruby reserved keyword, cannot be used in templates |
163 |
$django_module = $module |
164 |
file { "$name.wsgi": |
165 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
166 |
ensure => "present", |
167 |
owner => root, |
168 |
group => root, |
169 |
mode => 755, |
170 |
notify => Service['apache'], |
171 |
content => template("apache/django.wsgi") |
172 |
} |
173 |
} |
174 |
|
175 |
define vhost_wsgi($wsgi_path, $aliases = false) { |
176 |
include apache::mod_wsgi |
177 |
file { "$name.conf": |
178 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
179 |
ensure => "present", |
180 |
owner => root, |
181 |
group => root, |
182 |
mode => 644, |
183 |
notify => Service['apache'], |
184 |
content => template("apache/vhost_wsgi.conf") |
185 |
} |
186 |
} |
187 |
|
188 |
define vhost_other_app($vhost_file) { |
189 |
include apache::base |
190 |
file { "$name.conf": |
191 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
192 |
ensure => "present", |
193 |
owner => root, |
194 |
group => root, |
195 |
mode => 644, |
196 |
notify => Service['apache'], |
197 |
content => template($vhost_file) |
198 |
} |
199 |
} |
200 |
|
201 |
define vhost_simple($location) { |
202 |
include apache::base |
203 |
vhost_base { $name: |
204 |
location => $location, |
205 |
} |
206 |
} |
207 |
|
208 |
define vhost_redirect($url) { |
209 |
include apache::base |
210 |
vhost_base { $name: |
211 |
content => template("apache/vhost_redirect.conf"), |
212 |
} |
213 |
} |
214 |
|
215 |
define vhost_reverse_proxy($url) { |
216 |
include apache::mod_proxy |
217 |
vhost_base { $name: |
218 |
content => template("apache/vhost_reverse_proxy.conf") |
219 |
} |
220 |
} |
221 |
|
222 |
define webapp_other($webapp_file) { |
223 |
include apache::base |
224 |
$webappname = $name |
225 |
file { "webapp_$name.conf": |
226 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
227 |
ensure => "present", |
228 |
owner => root, |
229 |
group => root, |
230 |
mode => 644, |
231 |
notify => Service['apache'], |
232 |
content => template($webapp_file) |
233 |
} |
234 |
} |
235 |
} |