aboutsummaryrefslogtreecommitdiffstats
path: root/modules/apache/manifests/init.pp
blob: 782a16cdc03899d8abb3bac6ef47678689cc47f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
class apache {

    class base {
	$php_date_timezone = "UTC"

	# number of time the log file are rotated before being removed
	$httpdlogs_rotate = "24"

        package { "apache-mpm-prefork":
            alias => apache,
            ensure => installed
        }
    
        package { "apache-conf":
            ensure => installed,
        }

        service { httpd: 
            alias => apache,
            ensure => running,
            subscribe => [ Package['apache-mpm-prefork'] ],
        }

        file { "customization.conf":
            ensure => present,
            path => "/etc/httpd/conf.d/customization.conf",
            content => template("apache/customization.conf"),
            require => Package["apache-conf"],
            notify => Service["apache"],
            owner => root,
            group => root,
            mode => 644,
        }

        file { "00_default_vhosts.conf":
            path => "/etc/httpd/conf/vhosts.d/00_default_vhosts.conf",
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            notify => Service['apache'],
            require => Package["apache-conf"],
            content => template("apache/00_default_vhosts.conf")
        }

	file { "/etc/logrotate.d/httpd":
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            content => template("apache/logrotate")
	}

    }
    
    class mod_php inherits base {
        package { "apache-mod_php":
            ensure => installed
        }

        file { "/etc/httpd/conf.d/mod_php.conf":
            ensure => present,
            owner => root,
            group => root,
            mode => 644,
            require => Package['apache-conf'],
            content => template('apache/mod_php.conf'),
            notify => Service['apache'],
        }
    }

    class mod_perl inherits base {
        package { "apache-mod_perl":
            ensure => installed
        }
    }

    class mod_fcgid inherits base {
        package { "apache-mod_fcgid":
            ensure => installed
        }
    }

    class mod_fastcgi inherits base {
        package { "apache-mod_fastcgi":
            ensure => installed
        }
    }

    class mod_ssl inherits base {
        file { "/etc/ssl/apache/":
            ensure => directory
        }

        package { "apache-mod_ssl":
            ensure => installed
        }

	file { "01_default_ssl_vhost.conf":
	    path => '/etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf',
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            notify => Service['apache'],
            require => Package["apache-conf"],
            content => template("apache/01_default_ssl_vhost.conf")
	}

        file { "ssl.conf":
            ensure => present,
            path => "/etc/httpd/conf.d/ssl.conf",
            content => template("apache/ssl.conf"),
            require => Package["apache-conf"],
            notify => Service["apache"],
            owner => root,
            group => root,
            mode => 644,
        }
    }

    class mod_wsgi inherits base {
        package { "apache-mod_wsgi":
            ensure => installed
        }

        file { "/usr/local/lib/wsgi":
            ensure => directory,
            owner => root,
            group => root,
            mode => 644,
        }

        file { "/etc/httpd/conf.d/mod_wsgi.conf":
            ensure => present,
            owner => root,
            group => root,
            mode => 644,
            require => Package['apache-conf'],
            content => template('apache/mod_wsgi.conf'),
            notify => Service['apache'],
        }

    }
    
    class mod_proxy inherits base {
        package { "apache-mod_proxy":
            ensure => installed
        }
    }

    class mod_public_html inherits base {
        package { "apache-mod_public_html":
            ensure => installed
        }
    }

    class mod_deflate inherits base {
   	package { "apache-mod_deflate":
	    ensure => installed
	}
    }

    class mod_geoip inherits base {
	package { "apache-mod_geoip":
	    ensure => installed
	}
    }

    define vhost_base($content = '',
                      $location = '/dev/null', 
                      $use_ssl = false,
                      $vhost = false,
                      $aliases = {},
                      $server_aliases = [],
		      $access_logfile = false,
		      $error_logfile = false,
                      $options = [],
                      $enable_public_html = false) {
	include apache::base
	$httpd_logdir = "/var/log/httpd"
        if ! $vhost {
            $real_vhost = $name
        } else {
            $real_vhost = $vhost
        }

	if ! $access_logfile {
	    $real_access_logfile = "$httpd_logdir/${real_vhost}-access_log"
	} else {
	    $real_access_logfile = $access_logfile
	}
	if ! $error_logfile {
	    $real_error_logfile = "$httpd_logdir/${real_vhost}-error_log"
	} else {
	    $real_error_logfile = $error_logfile
	}

        if $use_ssl {
            include apache::mod_ssl
	    if $wildcard_sslcert != 'true' {
		openssl::self_signed_cert{ "$real_vhost":
		    directory => "/etc/ssl/apache/",
		    before => File["$filename"],
		}
	    }
        }

        if $enable_public_html {
            include apache::mod_public_html
        }

        $filename = "$name.conf"
        file { "$filename":
            path => "/etc/httpd/conf/vhosts.d/$filename",
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            notify => Service['apache'],
            require => Package['apache-conf'],
            content => template("apache/vhost_base.conf")
        }
    }

    define vhost_redirect_ssl() {
        vhost_base { "redirect_ssl_$name":
            vhost => $name,
            content => template("apache/vhost_ssl_redirect.conf")
        }
    }

    define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false, $vhost = false) {

        include apache::mod_fastcgi 
        vhost_base { $name:
	    vhost => $vhost,
            use_ssl => $use_ssl,
            content => template("apache/vhost_catalyst_app.conf")
        }
    }

    define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) {
        include apache::mod_wsgi
        vhost_base { $name:
            use_ssl => $use_ssl,
            content => template("apache/vhost_django_app.conf"),
            aliases => $aliases,
        }
        
        # module is a ruby reserved keyword, cannot be used in templates
        $django_module = $module
        file { "$name.wsgi":
            path => "/usr/local/lib/wsgi/$name.wsgi",
            ensure => "present",
            owner => root,
            group => root,
            mode => 755,
            notify => Service['apache'],
            content => template("apache/django.wsgi")
        }
    }

    define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) {
        include apache::mod_wsgi
        vhost_base { $name:
            aliases => $aliases,
            server_aliases => $server_aliases,
            content => template("apache/vhost_wsgi.conf")
        }
    }

   define vhost_other_app($vhost_file) {
        include apache::base
        file { "$name.conf":
            path => "/etc/httpd/conf/vhosts.d/$name.conf",
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            notify => Service['apache'],
            require => Package['apache-conf'],
            content => template($vhost_file)
        }
   }

    define vhost_simple($location) {
        include apache::base
        vhost_base { $name:
            location => $location,
        } 
    } 

    define vhost_redirect($url,
    			  $vhost = false,
			  $use_ssl = false) {
        include apache::base
        vhost_base { $name:
            use_ssl => $use_ssl,
            vhost => $vhost,
            content => template("apache/vhost_redirect.conf"),
        } 
    } 

    define vhost_reverse_proxy($url,
                               $vhost = false, 
                               $use_ssl = false) {
        include apache::mod_proxy
        vhost_base { $name:
            use_ssl => $use_ssl,
            vhost => $vhost,
            content => template("apache/vhost_reverse_proxy.conf")
        } 
    }

   define webapp_other($webapp_file) {
        include apache::base
        $webappname = $name
        file { "webapp_$name.conf":
            path => "/etc/httpd/conf/webapps.d/$webappname.conf",
            ensure => "present",
            owner => root,
            group => root,
            mode => 644,
            notify => Service['apache'],
            require => Package['apache-conf'],
            content => template($webapp_file)
        }
   }
}