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