1 |
class apache { |
class apache { |
2 |
|
|
3 |
|
define config($content) { |
4 |
|
file { $name: |
5 |
|
content => $content |
6 |
|
require => Package["apache-conf"], |
7 |
|
notify => Service["apache"], |
8 |
|
} |
9 |
|
} |
10 |
|
|
11 |
class base { |
class base { |
12 |
|
|
13 |
# number of time the log file are rotated before being removed |
# number of time the log file are rotated before being removed |
14 |
$httpdlogs_rotate = "24" |
$httpdlogs_rotate = "24" |
15 |
|
|
16 |
$apache_user = 'apache' |
$apache_user = 'apache' |
17 |
$apache_group = 'apache' |
$apache_group = 'apache' |
18 |
|
|
19 |
package { "apache-mpm-prefork": |
package { "apache-mpm-prefork": |
20 |
alias => apache, |
alias => apache, |
|
ensure => installed |
|
21 |
} |
} |
22 |
|
|
23 |
package { "apache-conf": |
package { "apache-conf": } |
|
ensure => installed, |
|
|
} |
|
24 |
|
|
25 |
service { httpd: |
service { httpd: |
26 |
alias => apache, |
alias => apache, |
28 |
subscribe => [ Package['apache-mpm-prefork'] ], |
subscribe => [ Package['apache-mpm-prefork'] ], |
29 |
} |
} |
30 |
|
|
31 |
file { "customization.conf": |
apache::config { |
32 |
ensure => present, |
"/etc/httpd/conf.d/customization.conf": |
33 |
path => "/etc/httpd/conf.d/customization.conf", |
content => template("apache/customization.conf"); |
34 |
content => template("apache/customization.conf"), |
"/etc/httpd/conf/vhosts.d/00_default_vhosts.conf": |
35 |
require => Package["apache-conf"], |
content => template("apache/00_default_vhosts.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") |
|
36 |
} |
} |
37 |
|
|
38 |
file { "/etc/logrotate.d/httpd": |
file { "/etc/logrotate.d/httpd": |
|
ensure => "present", |
|
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
39 |
content => template("apache/logrotate") |
content => template("apache/logrotate") |
40 |
} |
} |
|
|
|
41 |
} |
} |
42 |
|
|
43 |
class mod_php inherits base { |
class mod_php inherits base { |
44 |
$php_date_timezone = "UTC" |
$php_date_timezone = "UTC" |
|
package { "apache-mod_php": |
|
|
ensure => installed |
|
|
} |
|
45 |
|
|
46 |
file { "/etc/httpd/conf.d/mod_php.conf": |
package { "apache-mod_php": } |
47 |
ensure => present, |
|
48 |
owner => root, |
apache::config { "/etc/httpd/conf.d/mod_php.conf": |
|
group => root, |
|
|
mode => 644, |
|
|
require => Package['apache-conf'], |
|
49 |
content => template('apache/mod_php.conf'), |
content => template('apache/mod_php.conf'), |
|
notify => Service['apache'], |
|
50 |
} |
} |
51 |
} |
} |
52 |
|
|
53 |
class mod_perl inherits base { |
class mod_perl inherits base { |
54 |
package { "apache-mod_perl": |
package { "apache-mod_perl": } |
|
ensure => installed |
|
|
} |
|
55 |
} |
} |
56 |
|
|
57 |
class mod_fcgid inherits base { |
class mod_fcgid inherits base { |
58 |
package { "apache-mod_fcgid": |
package { "apache-mod_fcgid": } |
|
ensure => installed |
|
|
} |
|
59 |
} |
} |
60 |
|
|
61 |
class mod_fastcgi inherits base { |
class mod_fastcgi inherits base { |
62 |
package { "apache-mod_fastcgi": |
package { "apache-mod_fastcgi": } |
|
ensure => installed |
|
|
} |
|
63 |
} |
} |
64 |
|
|
65 |
class mod_ssl inherits base { |
class mod_ssl inherits base { |
67 |
ensure => directory |
ensure => directory |
68 |
} |
} |
69 |
|
|
70 |
package { "apache-mod_ssl": |
package { "apache-mod_ssl": } |
|
ensure => installed |
|
|
} |
|
71 |
|
|
72 |
file { "01_default_ssl_vhost.conf": |
apache::config { |
73 |
path => '/etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf', |
'/etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf': |
74 |
ensure => "present", |
content => template("apache/01_default_ssl_vhost.conf"); |
75 |
owner => root, |
"/etc/httpd/conf.d/ssl.conf": |
76 |
group => root, |
content => template("apache/ssl.conf"); |
|
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, |
|
77 |
} |
} |
78 |
} |
} |
79 |
|
|
80 |
class mod_wsgi inherits base { |
class mod_wsgi inherits base { |
81 |
package { "apache-mod_wsgi": |
package { "apache-mod_wsgi": } |
|
ensure => installed |
|
|
} |
|
82 |
|
|
83 |
file { "/usr/local/lib/wsgi": |
file { "/usr/local/lib/wsgi": |
84 |
ensure => directory, |
ensure => directory, |
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
85 |
} |
} |
86 |
|
|
87 |
file { "/etc/httpd/conf.d/mod_wsgi.conf": |
apache::config { "/etc/httpd/conf.d/mod_wsgi.conf": |
|
ensure => present, |
|
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
|
require => Package['apache-conf'], |
|
88 |
content => template('apache/mod_wsgi.conf'), |
content => template('apache/mod_wsgi.conf'), |
|
notify => Service['apache'], |
|
89 |
} |
} |
|
|
|
90 |
} |
} |
91 |
|
|
92 |
class mod_proxy inherits base { |
class mod_proxy inherits base { |
93 |
package { "apache-mod_proxy": |
package { "apache-mod_proxy": } |
|
ensure => installed |
|
|
} |
|
94 |
} |
} |
95 |
|
|
96 |
class mod_public_html inherits base { |
class mod_public_html inherits base { |
97 |
package { "apache-mod_public_html": |
package { "apache-mod_public_html": } |
|
ensure => installed |
|
|
} |
|
98 |
} |
} |
99 |
|
|
100 |
class mod_deflate inherits base { |
class mod_deflate inherits base { |
101 |
package { "apache-mod_deflate": |
package { "apache-mod_deflate": } |
|
ensure => installed |
|
|
} |
|
102 |
} |
} |
103 |
|
|
104 |
class mod_geoip inherits base { |
class mod_geoip inherits base { |
105 |
package { "apache-mod_geoip": |
package { "apache-mod_geoip": } |
|
ensure => installed |
|
|
} |
|
106 |
} |
} |
107 |
|
|
108 |
define vhost_base($content = '', |
define vhost_base($content = '', |
111 |
$vhost = false, |
$vhost = false, |
112 |
$aliases = {}, |
$aliases = {}, |
113 |
$server_aliases = [], |
$server_aliases = [], |
114 |
$access_logfile = false, |
$access_logfile = false, |
115 |
$error_logfile = false, |
$error_logfile = false, |
116 |
$options = [], |
$options = [], |
117 |
$enable_public_html = false) { |
$enable_public_html = false) { |
118 |
include apache::base |
include apache::base |
119 |
$httpd_logdir = "/var/log/httpd" |
$httpd_logdir = "/var/log/httpd" |
120 |
|
|
121 |
if ! $vhost { |
if ! $vhost { |
122 |
$real_vhost = $name |
$real_vhost = $name |
123 |
} else { |
} else { |
124 |
$real_vhost = $vhost |
$real_vhost = $vhost |
125 |
} |
} |
126 |
|
|
127 |
if ! $access_logfile { |
if ! $access_logfile { |
128 |
$real_access_logfile = "$httpd_logdir/${real_vhost}-access_log" |
$real_access_logfile = "$httpd_logdir/${real_vhost}-access_log" |
129 |
} else { |
} else { |
130 |
$real_access_logfile = $access_logfile |
$real_access_logfile = $access_logfile |
131 |
} |
} |
132 |
if ! $error_logfile { |
if ! $error_logfile { |
133 |
$real_error_logfile = "$httpd_logdir/${real_vhost}-error_log" |
$real_error_logfile = "$httpd_logdir/${real_vhost}-error_log" |
134 |
} else { |
} else { |
135 |
$real_error_logfile = $error_logfile |
$real_error_logfile = $error_logfile |
136 |
} |
} |
137 |
|
|
138 |
if $use_ssl { |
if $use_ssl { |
139 |
include apache::mod_ssl |
include apache::mod_ssl |
140 |
if $wildcard_sslcert != 'true' { |
if $wildcard_sslcert != 'true' { |
141 |
openssl::self_signed_cert{ "$real_vhost": |
openssl::self_signed_cert{ "$real_vhost": |
142 |
directory => "/etc/ssl/apache/", |
directory => "/etc/ssl/apache/", |
143 |
before => File["$filename"], |
before => File["$filename"], |
144 |
} |
} |
145 |
} |
} |
146 |
} |
} |
147 |
|
|
148 |
if $enable_public_html { |
if $enable_public_html { |
150 |
} |
} |
151 |
|
|
152 |
$filename = "$name.conf" |
$filename = "$name.conf" |
153 |
file { "$filename": |
apache::config { "/etc/httpd/conf/vhosts.d/$filename": |
|
path => "/etc/httpd/conf/vhosts.d/$filename", |
|
|
ensure => "present", |
|
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
|
notify => Service['apache'], |
|
|
require => Package['apache-conf'], |
|
154 |
content => template("apache/vhost_base.conf") |
content => template("apache/vhost_base.conf") |
155 |
} |
} |
156 |
} |
} |
166 |
|
|
167 |
include apache::mod_fastcgi |
include apache::mod_fastcgi |
168 |
vhost_base { $name: |
vhost_base { $name: |
169 |
vhost => $vhost, |
vhost => $vhost, |
170 |
use_ssl => $use_ssl, |
use_ssl => $use_ssl, |
171 |
content => template("apache/vhost_catalyst_app.conf") |
content => template("apache/vhost_catalyst_app.conf"), |
172 |
} |
} |
173 |
} |
} |
174 |
|
|
184 |
$django_module = $module |
$django_module = $module |
185 |
file { "$name.wsgi": |
file { "$name.wsgi": |
186 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
path => "/usr/local/lib/wsgi/$name.wsgi", |
|
ensure => "present", |
|
|
owner => root, |
|
|
group => root, |
|
187 |
mode => 755, |
mode => 755, |
188 |
notify => Service['apache'], |
notify => Service['apache'], |
189 |
content => template("apache/django.wsgi") |
content => template("apache/django.wsgi"), |
190 |
} |
} |
191 |
} |
} |
192 |
|
|
195 |
vhost_base { $name: |
vhost_base { $name: |
196 |
aliases => $aliases, |
aliases => $aliases, |
197 |
server_aliases => $server_aliases, |
server_aliases => $server_aliases, |
198 |
content => template("apache/vhost_wsgi.conf") |
content => template("apache/vhost_wsgi.conf"), |
199 |
} |
} |
200 |
} |
} |
201 |
|
|
202 |
define vhost_other_app($vhost_file) { |
define vhost_other_app($vhost_file) { |
203 |
include apache::base |
include apache::base |
204 |
file { "$name.conf": |
apache::config { "/etc/httpd/conf/vhosts.d/$name.conf": |
205 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
content => template($vhost_file), |
|
ensure => "present", |
|
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
|
notify => Service['apache'], |
|
|
require => Package['apache-conf'], |
|
|
content => template($vhost_file) |
|
206 |
} |
} |
207 |
} |
} |
208 |
|
|
214 |
} |
} |
215 |
|
|
216 |
define vhost_redirect($url, |
define vhost_redirect($url, |
217 |
$vhost = false, |
$vhost = false, |
218 |
$use_ssl = false) { |
$use_ssl = false) { |
219 |
include apache::base |
include apache::base |
220 |
vhost_base { $name: |
vhost_base { $name: |
221 |
use_ssl => $use_ssl, |
use_ssl => $use_ssl, |
235 |
} |
} |
236 |
} |
} |
237 |
|
|
238 |
define webapp_other($webapp_file) { |
define webapp_other($webapp_file) { |
239 |
include apache::base |
include apache::base |
240 |
$webappname = $name |
$webappname = $name |
241 |
file { "webapp_$name.conf": |
apache::config { "/etc/httpd/conf/webapps.d/$webappname.conf": |
242 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
content => template($webapp_file), |
|
ensure => "present", |
|
|
owner => root, |
|
|
group => root, |
|
|
mode => 644, |
|
|
notify => Service['apache'], |
|
|
require => Package['apache-conf'], |
|
|
content => template($webapp_file) |
|
243 |
} |
} |
244 |
} |
} |
245 |
} |
} |