/[adm]/puppet/modules/apache/manifests/init.pp
ViewVC logotype

Contents of /puppet/modules/apache/manifests/init.pp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.30