1 |
class apache { |
2 |
define vhost_base($content = '', |
3 |
$location = '/dev/null', |
4 |
$use_ssl = false, |
5 |
$vhost = false, |
6 |
$aliases = {}, |
7 |
$server_aliases = [], |
8 |
$access_logfile = false, |
9 |
$error_logfile = false, |
10 |
$options = [], |
11 |
$enable_public_html = false) { |
12 |
include apache::base |
13 |
$httpd_logdir = "/var/log/httpd" |
14 |
$filename = "$name.conf" |
15 |
|
16 |
if ! $vhost { |
17 |
$real_vhost = $name |
18 |
} else { |
19 |
$real_vhost = $vhost |
20 |
} |
21 |
|
22 |
if ! $access_logfile { |
23 |
$real_access_logfile = "$httpd_logdir/${real_vhost}-access_log" |
24 |
} else { |
25 |
$real_access_logfile = $access_logfile |
26 |
} |
27 |
if ! $error_logfile { |
28 |
$real_error_logfile = "$httpd_logdir/${real_vhost}-error_log" |
29 |
} else { |
30 |
$real_error_logfile = $error_logfile |
31 |
} |
32 |
|
33 |
if $use_ssl { |
34 |
include apache::mod::ssl |
35 |
if $wildcard_sslcert != 'true' { |
36 |
openssl::self_signed_cert{ "$real_vhost": |
37 |
directory => "/etc/ssl/apache/", |
38 |
before => Apache::Config["/etc/httpd/conf/vhosts.d/$filename"], |
39 |
} |
40 |
} |
41 |
} |
42 |
|
43 |
if $enable_public_html { |
44 |
include apache::mod::public_html |
45 |
} |
46 |
|
47 |
apache::config { "/etc/httpd/conf/vhosts.d/$filename": |
48 |
content => template("apache/vhost_base.conf") |
49 |
} |
50 |
} |
51 |
|
52 |
define vhost_redirect_ssl() { |
53 |
vhost_base { "redirect_ssl_$name": |
54 |
vhost => $name, |
55 |
content => template("apache/vhost_ssl_redirect.conf") |
56 |
} |
57 |
} |
58 |
|
59 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false, $vhost = false) { |
60 |
|
61 |
include apache::mod::fastcgi |
62 |
vhost_base { $name: |
63 |
vhost => $vhost, |
64 |
use_ssl => $use_ssl, |
65 |
content => template("apache/vhost_catalyst_app.conf"), |
66 |
} |
67 |
} |
68 |
|
69 |
define vhost_django_app($module = false, $module_path = false, $use_ssl = false, $aliases= {}) { |
70 |
include apache::mod::wsgi |
71 |
vhost_base { $name: |
72 |
use_ssl => $use_ssl, |
73 |
content => template("apache/vhost_django_app.conf"), |
74 |
aliases => $aliases, |
75 |
} |
76 |
|
77 |
# module is a ruby reserved keyword, cannot be used in templates |
78 |
$django_module = $module |
79 |
file { "$name.wsgi": |
80 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
81 |
mode => 755, |
82 |
notify => Service['apache'], |
83 |
content => template("apache/django.wsgi"), |
84 |
} |
85 |
} |
86 |
|
87 |
define vhost_wsgi($wsgi_path, $aliases = {}, $server_aliases = []) { |
88 |
include apache::mod::wsgi |
89 |
vhost_base { $name: |
90 |
aliases => $aliases, |
91 |
server_aliases => $server_aliases, |
92 |
content => template("apache/vhost_wsgi.conf"), |
93 |
} |
94 |
} |
95 |
|
96 |
define vhost_other_app($vhost_file) { |
97 |
include apache::base |
98 |
apache::config { "/etc/httpd/conf/vhosts.d/$name.conf": |
99 |
content => template($vhost_file), |
100 |
} |
101 |
} |
102 |
|
103 |
define vhost_simple($location) { |
104 |
include apache::base |
105 |
vhost_base { $name: |
106 |
location => $location, |
107 |
} |
108 |
} |
109 |
|
110 |
define vhost_redirect($url, |
111 |
$vhost = false, |
112 |
$use_ssl = false) { |
113 |
include apache::base |
114 |
vhost_base { $name: |
115 |
use_ssl => $use_ssl, |
116 |
vhost => $vhost, |
117 |
content => template("apache/vhost_redirect.conf"), |
118 |
} |
119 |
} |
120 |
|
121 |
define vhost_reverse_proxy($url, |
122 |
$vhost = false, |
123 |
$use_ssl = false) { |
124 |
include apache::mod::proxy |
125 |
vhost_base { $name: |
126 |
use_ssl => $use_ssl, |
127 |
vhost => $vhost, |
128 |
content => template("apache/vhost_reverse_proxy.conf") |
129 |
} |
130 |
} |
131 |
|
132 |
} |