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 |
misc |
2686 |
|
39 |
misc |
928 |
define vhost_base($content = '', |
40 |
|
|
$location = '/dev/null', |
41 |
|
|
$use_ssl = false, |
42 |
misc |
930 |
$vhost = false, |
43 |
misc |
932 |
$aliases = {}, |
44 |
misc |
935 |
$server_aliases = [], |
45 |
misc |
2225 |
$access_logfile = false, |
46 |
|
|
$error_logfile = false, |
47 |
pterjan |
1599 |
$options = [], |
48 |
misc |
930 |
$enable_public_html = false) { |
49 |
misc |
2225 |
include apache::base |
50 |
|
|
$httpd_logdir = "/var/log/httpd" |
51 |
misc |
2488 |
$filename = "$name.conf" |
52 |
misc |
2225 |
|
53 |
misc |
928 |
if ! $vhost { |
54 |
|
|
$real_vhost = $name |
55 |
|
|
} else { |
56 |
|
|
$real_vhost = $vhost |
57 |
misc |
176 |
} |
58 |
misc |
167 |
|
59 |
misc |
2225 |
if ! $access_logfile { |
60 |
|
|
$real_access_logfile = "$httpd_logdir/${real_vhost}-access_log" |
61 |
|
|
} else { |
62 |
|
|
$real_access_logfile = $access_logfile |
63 |
|
|
} |
64 |
|
|
if ! $error_logfile { |
65 |
|
|
$real_error_logfile = "$httpd_logdir/${real_vhost}-error_log" |
66 |
|
|
} else { |
67 |
|
|
$real_error_logfile = $error_logfile |
68 |
|
|
} |
69 |
boklm |
1630 |
|
70 |
misc |
489 |
if $use_ssl { |
71 |
misc |
2681 |
include apache::mod::ssl |
72 |
misc |
2225 |
if $wildcard_sslcert != 'true' { |
73 |
|
|
openssl::self_signed_cert{ "$real_vhost": |
74 |
|
|
directory => "/etc/ssl/apache/", |
75 |
misc |
2488 |
before => Apache::Config["/etc/httpd/conf/vhosts.d/$filename"], |
76 |
misc |
2225 |
} |
77 |
|
|
} |
78 |
misc |
489 |
} |
79 |
|
|
|
80 |
misc |
930 |
if $enable_public_html { |
81 |
misc |
2682 |
include apache::mod::public_html |
82 |
misc |
930 |
} |
83 |
|
|
|
84 |
misc |
2225 |
apache::config { "/etc/httpd/conf/vhosts.d/$filename": |
85 |
misc |
928 |
content => template("apache/vhost_base.conf") |
86 |
|
|
} |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
define vhost_redirect_ssl() { |
90 |
|
|
vhost_base { "redirect_ssl_$name": |
91 |
|
|
vhost => $name, |
92 |
|
|
content => template("apache/vhost_ssl_redirect.conf") |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
|
96 |
boklm |
1617 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false, $vhost = false) { |
97 |
misc |
928 |
|
98 |
misc |
2684 |
include apache::mod::fastcgi |
99 |
misc |
928 |
vhost_base { $name: |
100 |
misc |
2225 |
vhost => $vhost, |
101 |
misc |
928 |
use_ssl => $use_ssl, |
102 |
misc |
2225 |
content => template("apache/vhost_catalyst_app.conf"), |
103 |
misc |
167 |
} |
104 |
|
|
} |
105 |
misc |
182 |
|
106 |
misc |
1193 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) { |
107 |
misc |
2686 |
include apache::mod::wsgi |
108 |
misc |
928 |
vhost_base { $name: |
109 |
misc |
934 |
use_ssl => $use_ssl, |
110 |
misc |
1193 |
content => template("apache/vhost_django_app.conf"), |
111 |
|
|
aliases => $aliases, |
112 |
misc |
621 |
} |
113 |
misc |
928 |
|
114 |
misc |
612 |
# module is a ruby reserved keyword, cannot be used in templates |
115 |
|
|
$django_module = $module |
116 |
misc |
182 |
file { "$name.wsgi": |
117 |
misc |
201 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
118 |
misc |
182 |
mode => 755, |
119 |
|
|
notify => Service['apache'], |
120 |
misc |
2225 |
content => template("apache/django.wsgi"), |
121 |
misc |
182 |
} |
122 |
|
|
} |
123 |
boklm |
280 |
|
124 |
misc |
935 |
define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) { |
125 |
misc |
2686 |
include apache::mod::wsgi |
126 |
misc |
933 |
vhost_base { $name: |
127 |
|
|
aliases => $aliases, |
128 |
misc |
935 |
server_aliases => $server_aliases, |
129 |
misc |
2225 |
content => template("apache/vhost_wsgi.conf"), |
130 |
misc |
812 |
} |
131 |
|
|
} |
132 |
|
|
|
133 |
boklm |
280 |
define vhost_other_app($vhost_file) { |
134 |
misc |
412 |
include apache::base |
135 |
misc |
2225 |
apache::config { "/etc/httpd/conf/vhosts.d/$name.conf": |
136 |
|
|
content => template($vhost_file), |
137 |
boklm |
280 |
} |
138 |
|
|
} |
139 |
|
|
|
140 |
misc |
742 |
define vhost_simple($location) { |
141 |
|
|
include apache::base |
142 |
misc |
928 |
vhost_base { $name: |
143 |
|
|
location => $location, |
144 |
|
|
} |
145 |
misc |
742 |
} |
146 |
|
|
|
147 |
boklm |
1319 |
define vhost_redirect($url, |
148 |
misc |
2225 |
$vhost = false, |
149 |
|
|
$use_ssl = false) { |
150 |
misc |
931 |
include apache::base |
151 |
|
|
vhost_base { $name: |
152 |
boklm |
1319 |
use_ssl => $use_ssl, |
153 |
|
|
vhost => $vhost, |
154 |
misc |
931 |
content => template("apache/vhost_redirect.conf"), |
155 |
|
|
} |
156 |
|
|
} |
157 |
|
|
|
158 |
misc |
1103 |
define vhost_reverse_proxy($url, |
159 |
|
|
$vhost = false, |
160 |
|
|
$use_ssl = false) { |
161 |
misc |
2682 |
include apache::mod::proxy |
162 |
misc |
928 |
vhost_base { $name: |
163 |
misc |
1102 |
use_ssl => $use_ssl, |
164 |
misc |
1103 |
vhost => $vhost, |
165 |
misc |
778 |
content => template("apache/vhost_reverse_proxy.conf") |
166 |
misc |
928 |
} |
167 |
misc |
778 |
} |
168 |
|
|
|
169 |
misc |
80 |
} |