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 |
define vhost_base($content = '', |
100 |
$location = '/dev/null', |
101 |
$use_ssl = false, |
102 |
$vhost = false) { |
103 |
if ! $vhost { |
104 |
$real_vhost = $name |
105 |
} else { |
106 |
$real_vhost = $vhost |
107 |
} |
108 |
|
109 |
if $use_ssl { |
110 |
include apache::mod_ssl |
111 |
openssl::self_signed_cert{ "$name": |
112 |
directory => "/etc/ssl/apache/", |
113 |
before => File["$filename"], |
114 |
} |
115 |
} |
116 |
|
117 |
$filename = "$name.conf" |
118 |
file { "$filename": |
119 |
path => "/etc/httpd/conf/vhosts.d/$filename", |
120 |
ensure => "present", |
121 |
owner => root, |
122 |
group => root, |
123 |
mode => 644, |
124 |
notify => Service['apache'], |
125 |
content => template("apache/vhost_base.conf") |
126 |
} |
127 |
} |
128 |
|
129 |
define vhost_redirect_ssl() { |
130 |
vhost_base { "redirect_ssl_$name": |
131 |
vhost => $name, |
132 |
content => template("apache/vhost_ssl_redirect.conf") |
133 |
} |
134 |
} |
135 |
|
136 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { |
137 |
|
138 |
include apache::mod_fastcgi |
139 |
vhost_base { $name: |
140 |
use_ssl => $use_ssl, |
141 |
content => template("apache/vhost_catalyst_app.conf") |
142 |
} |
143 |
} |
144 |
|
145 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false) { |
146 |
include apache::mod_wsgi |
147 |
vhost_base { $name: |
148 |
content => template("apache/vhost_django_app.conf") |
149 |
} |
150 |
|
151 |
# module is a ruby reserved keyword, cannot be used in templates |
152 |
$django_module = $module |
153 |
file { "$name.wsgi": |
154 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
155 |
ensure => "present", |
156 |
owner => root, |
157 |
group => root, |
158 |
mode => 755, |
159 |
notify => Service['apache'], |
160 |
content => template("apache/django.wsgi") |
161 |
} |
162 |
} |
163 |
|
164 |
define vhost_wsgi($wsgi_path, $aliases = false) { |
165 |
include apache::mod_wsgi |
166 |
file { "$name.conf": |
167 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
168 |
ensure => "present", |
169 |
owner => root, |
170 |
group => root, |
171 |
mode => 644, |
172 |
notify => Service['apache'], |
173 |
content => template("apache/vhost_wsgi.conf") |
174 |
} |
175 |
} |
176 |
|
177 |
define vhost_other_app($vhost_file) { |
178 |
include apache::base |
179 |
file { "$name.conf": |
180 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
181 |
ensure => "present", |
182 |
owner => root, |
183 |
group => root, |
184 |
mode => 644, |
185 |
notify => Service['apache'], |
186 |
content => template($vhost_file) |
187 |
} |
188 |
} |
189 |
|
190 |
define vhost_simple($location) { |
191 |
include apache::base |
192 |
vhost_base { $name: |
193 |
location => $location, |
194 |
} |
195 |
} |
196 |
|
197 |
define vhost_reverse_proxy($url) { |
198 |
include apache::mod_proxy |
199 |
vhost_base { $name: |
200 |
content => template("apache/vhost_reverse_proxy.conf") |
201 |
} |
202 |
} |
203 |
|
204 |
define webapp_other($webapp_file) { |
205 |
include apache::base |
206 |
$webappname = $name |
207 |
file { "webapp_$name.conf": |
208 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
209 |
ensure => "present", |
210 |
owner => root, |
211 |
group => root, |
212 |
mode => 644, |
213 |
notify => Service['apache'], |
214 |
content => template($webapp_file) |
215 |
} |
216 |
} |
217 |
} |