1 |
misc |
80 |
class apache { |
2 |
|
|
class base { |
3 |
boklm |
1500 |
|
4 |
misc |
2225 |
# number of time the log file are rotated before being removed |
5 |
|
|
$httpdlogs_rotate = "24" |
6 |
boklm |
1636 |
|
7 |
misc |
2225 |
$apache_user = 'apache' |
8 |
|
|
$apache_group = 'apache' |
9 |
boklm |
2104 |
|
10 |
misc |
80 |
package { "apache-mpm-prefork": |
11 |
misc |
117 |
alias => apache, |
12 |
misc |
80 |
} |
13 |
|
|
|
14 |
misc |
2225 |
package { "apache-conf": } |
15 |
misc |
1065 |
|
16 |
misc |
96 |
service { httpd: |
17 |
|
|
alias => apache, |
18 |
misc |
80 |
subscribe => [ Package['apache-mpm-prefork'] ], |
19 |
|
|
} |
20 |
misc |
117 |
|
21 |
misc |
2243 |
exec { "service httpd configtest": |
22 |
|
|
refreshonly => true, |
23 |
|
|
notify => Service["apache"], |
24 |
|
|
} |
25 |
|
|
|
26 |
misc |
2225 |
apache::config { |
27 |
|
|
"/etc/httpd/conf.d/customization.conf": |
28 |
|
|
content => template("apache/customization.conf"); |
29 |
|
|
"/etc/httpd/conf/vhosts.d/00_default_vhosts.conf": |
30 |
|
|
content => template("apache/00_default_vhosts.conf"); |
31 |
misc |
117 |
} |
32 |
boklm |
207 |
|
33 |
misc |
2225 |
file { "/etc/logrotate.d/httpd": |
34 |
|
|
content => template("apache/logrotate") |
35 |
boklm |
207 |
} |
36 |
misc |
80 |
} |
37 |
|
|
|
38 |
|
|
class mod_wsgi inherits base { |
39 |
misc |
2225 |
package { "apache-mod_wsgi": } |
40 |
misc |
182 |
|
41 |
misc |
201 |
file { "/usr/local/lib/wsgi": |
42 |
misc |
182 |
ensure => directory, |
43 |
|
|
} |
44 |
misc |
908 |
|
45 |
misc |
2225 |
apache::config { "/etc/httpd/conf.d/mod_wsgi.conf": |
46 |
misc |
1188 |
content => template('apache/mod_wsgi.conf'), |
47 |
misc |
908 |
} |
48 |
misc |
2225 |
} |
49 |
misc |
908 |
|
50 |
misc |
167 |
|
51 |
misc |
928 |
define vhost_base($content = '', |
52 |
|
|
$location = '/dev/null', |
53 |
|
|
$use_ssl = false, |
54 |
misc |
930 |
$vhost = false, |
55 |
misc |
932 |
$aliases = {}, |
56 |
misc |
935 |
$server_aliases = [], |
57 |
misc |
2225 |
$access_logfile = false, |
58 |
|
|
$error_logfile = false, |
59 |
pterjan |
1599 |
$options = [], |
60 |
misc |
930 |
$enable_public_html = false) { |
61 |
misc |
2225 |
include apache::base |
62 |
|
|
$httpd_logdir = "/var/log/httpd" |
63 |
misc |
2488 |
$filename = "$name.conf" |
64 |
misc |
2225 |
|
65 |
misc |
928 |
if ! $vhost { |
66 |
|
|
$real_vhost = $name |
67 |
|
|
} else { |
68 |
|
|
$real_vhost = $vhost |
69 |
misc |
176 |
} |
70 |
misc |
167 |
|
71 |
misc |
2225 |
if ! $access_logfile { |
72 |
|
|
$real_access_logfile = "$httpd_logdir/${real_vhost}-access_log" |
73 |
|
|
} else { |
74 |
|
|
$real_access_logfile = $access_logfile |
75 |
|
|
} |
76 |
|
|
if ! $error_logfile { |
77 |
|
|
$real_error_logfile = "$httpd_logdir/${real_vhost}-error_log" |
78 |
|
|
} else { |
79 |
|
|
$real_error_logfile = $error_logfile |
80 |
|
|
} |
81 |
boklm |
1630 |
|
82 |
misc |
489 |
if $use_ssl { |
83 |
misc |
2681 |
include apache::mod::ssl |
84 |
misc |
2225 |
if $wildcard_sslcert != 'true' { |
85 |
|
|
openssl::self_signed_cert{ "$real_vhost": |
86 |
|
|
directory => "/etc/ssl/apache/", |
87 |
misc |
2488 |
before => Apache::Config["/etc/httpd/conf/vhosts.d/$filename"], |
88 |
misc |
2225 |
} |
89 |
|
|
} |
90 |
misc |
489 |
} |
91 |
|
|
|
92 |
misc |
930 |
if $enable_public_html { |
93 |
misc |
2682 |
include apache::mod::public_html |
94 |
misc |
930 |
} |
95 |
|
|
|
96 |
misc |
2225 |
apache::config { "/etc/httpd/conf/vhosts.d/$filename": |
97 |
misc |
928 |
content => template("apache/vhost_base.conf") |
98 |
|
|
} |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
define vhost_redirect_ssl() { |
102 |
|
|
vhost_base { "redirect_ssl_$name": |
103 |
|
|
vhost => $name, |
104 |
|
|
content => template("apache/vhost_ssl_redirect.conf") |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
|
108 |
boklm |
1617 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false, $vhost = false) { |
109 |
misc |
928 |
|
110 |
misc |
2684 |
include apache::mod::fastcgi |
111 |
misc |
928 |
vhost_base { $name: |
112 |
misc |
2225 |
vhost => $vhost, |
113 |
misc |
928 |
use_ssl => $use_ssl, |
114 |
misc |
2225 |
content => template("apache/vhost_catalyst_app.conf"), |
115 |
misc |
167 |
} |
116 |
|
|
} |
117 |
misc |
182 |
|
118 |
misc |
1193 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) { |
119 |
misc |
182 |
include apache::mod_wsgi |
120 |
misc |
928 |
vhost_base { $name: |
121 |
misc |
934 |
use_ssl => $use_ssl, |
122 |
misc |
1193 |
content => template("apache/vhost_django_app.conf"), |
123 |
|
|
aliases => $aliases, |
124 |
misc |
621 |
} |
125 |
misc |
928 |
|
126 |
misc |
612 |
# module is a ruby reserved keyword, cannot be used in templates |
127 |
|
|
$django_module = $module |
128 |
misc |
182 |
file { "$name.wsgi": |
129 |
misc |
201 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
130 |
misc |
182 |
mode => 755, |
131 |
|
|
notify => Service['apache'], |
132 |
misc |
2225 |
content => template("apache/django.wsgi"), |
133 |
misc |
182 |
} |
134 |
|
|
} |
135 |
boklm |
280 |
|
136 |
misc |
935 |
define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) { |
137 |
misc |
812 |
include apache::mod_wsgi |
138 |
misc |
933 |
vhost_base { $name: |
139 |
|
|
aliases => $aliases, |
140 |
misc |
935 |
server_aliases => $server_aliases, |
141 |
misc |
2225 |
content => template("apache/vhost_wsgi.conf"), |
142 |
misc |
812 |
} |
143 |
|
|
} |
144 |
|
|
|
145 |
boklm |
280 |
define vhost_other_app($vhost_file) { |
146 |
misc |
412 |
include apache::base |
147 |
misc |
2225 |
apache::config { "/etc/httpd/conf/vhosts.d/$name.conf": |
148 |
|
|
content => template($vhost_file), |
149 |
boklm |
280 |
} |
150 |
|
|
} |
151 |
|
|
|
152 |
misc |
742 |
define vhost_simple($location) { |
153 |
|
|
include apache::base |
154 |
misc |
928 |
vhost_base { $name: |
155 |
|
|
location => $location, |
156 |
|
|
} |
157 |
misc |
742 |
} |
158 |
|
|
|
159 |
boklm |
1319 |
define vhost_redirect($url, |
160 |
misc |
2225 |
$vhost = false, |
161 |
|
|
$use_ssl = false) { |
162 |
misc |
931 |
include apache::base |
163 |
|
|
vhost_base { $name: |
164 |
boklm |
1319 |
use_ssl => $use_ssl, |
165 |
|
|
vhost => $vhost, |
166 |
misc |
931 |
content => template("apache/vhost_redirect.conf"), |
167 |
|
|
} |
168 |
|
|
} |
169 |
|
|
|
170 |
misc |
1103 |
define vhost_reverse_proxy($url, |
171 |
|
|
$vhost = false, |
172 |
|
|
$use_ssl = false) { |
173 |
misc |
2682 |
include apache::mod::proxy |
174 |
misc |
928 |
vhost_base { $name: |
175 |
misc |
1102 |
use_ssl => $use_ssl, |
176 |
misc |
1103 |
vhost => $vhost, |
177 |
misc |
778 |
content => template("apache/vhost_reverse_proxy.conf") |
178 |
misc |
928 |
} |
179 |
misc |
778 |
} |
180 |
|
|
|
181 |
misc |
2225 |
define webapp_other($webapp_file) { |
182 |
misc |
422 |
include apache::base |
183 |
boklm |
280 |
$webappname = $name |
184 |
misc |
2225 |
apache::config { "/etc/httpd/conf/webapps.d/$webappname.conf": |
185 |
|
|
content => template($webapp_file), |
186 |
boklm |
280 |
} |
187 |
misc |
2225 |
} |
188 |
misc |
80 |
} |