1 |
class apache { |
2 |
|
3 |
class base { |
4 |
package { "apache-mpm-prefork": |
5 |
alias => apache, |
6 |
ensure => installed |
7 |
} |
8 |
|
9 |
service { httpd: |
10 |
alias => apache, |
11 |
ensure => running, |
12 |
subscribe => [ Package['apache-mpm-prefork'] ], |
13 |
} |
14 |
|
15 |
file { "customization.conf": |
16 |
ensure => present, |
17 |
path => "/etc/httpd/conf.d/customization.conf", |
18 |
content => template("apache/customization.conf"), |
19 |
require => Package["apache"], |
20 |
notify => Service["apache"], |
21 |
owner => root, |
22 |
group => root, |
23 |
mode => 644, |
24 |
} |
25 |
|
26 |
file { "00_default_vhosts.conf": |
27 |
path => "/etc/httpd/conf/vhosts.d/00_default_vhosts.conf", |
28 |
ensure => "present", |
29 |
owner => root, |
30 |
group => root, |
31 |
mode => 644, |
32 |
notify => Service['apache'], |
33 |
content => template("apache/00_default_vhosts.conf") |
34 |
} |
35 |
} |
36 |
|
37 |
class mod_php inherits base { |
38 |
package { "apache-mod_php": |
39 |
ensure => installed |
40 |
} |
41 |
} |
42 |
|
43 |
class mod_perl inherits base { |
44 |
package { "apache-mod_perl": |
45 |
ensure => installed |
46 |
} |
47 |
} |
48 |
|
49 |
class mod_fcgid inherits base { |
50 |
package { "apache-mod_fcgid": |
51 |
ensure => installed |
52 |
} |
53 |
} |
54 |
|
55 |
class mod_fastcgi inherits base { |
56 |
package { "apache-mod_fastcgi": |
57 |
ensure => installed |
58 |
} |
59 |
} |
60 |
|
61 |
class mod_ssl inherits base { |
62 |
file { "/etc/ssl/apache/": |
63 |
ensure => directory |
64 |
} |
65 |
|
66 |
package { "apache-mod_ssl": |
67 |
ensure => installed |
68 |
} |
69 |
} |
70 |
|
71 |
class mod_wsgi inherits base { |
72 |
package { "apache-mod_wsgi": |
73 |
ensure => installed |
74 |
} |
75 |
|
76 |
file { "/usr/local/lib/wsgi": |
77 |
ensure => directory, |
78 |
owner => root, |
79 |
group => root, |
80 |
mode => 644, |
81 |
} |
82 |
} |
83 |
|
84 |
define vhost_redirect_ssl() { |
85 |
file { "redirect_ssl_$name.conf": |
86 |
path => "/etc/httpd/conf/vhosts.d/redirect_ssl_$name.conf", |
87 |
ensure => "present", |
88 |
owner => root, |
89 |
group => root, |
90 |
mode => 644, |
91 |
notify => Service['apache'], |
92 |
content => template("apache/vhost_ssl_redirect.conf") |
93 |
} |
94 |
} |
95 |
|
96 |
define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { |
97 |
|
98 |
include apache::mod_fastcgi |
99 |
|
100 |
if $use_ssl { |
101 |
include apache::mod_ssl |
102 |
openssl::self_signed_cert{ "$name": |
103 |
directory => "/etc/ssl/apache/", |
104 |
before => File["$name.conf"], |
105 |
} |
106 |
} |
107 |
|
108 |
file { "$name.conf": |
109 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
110 |
ensure => "present", |
111 |
owner => root, |
112 |
group => root, |
113 |
mode => 644, |
114 |
notify => Service['apache'], |
115 |
content => template("apache/vhost_catalyst_app.conf") |
116 |
} |
117 |
} |
118 |
|
119 |
define vhost_django_app($module = false, $module_path = false) { |
120 |
include apache::mod_wsgi |
121 |
|
122 |
# module is a ruby reserved keyword, cannot be used in templates |
123 |
$django_module = $module |
124 |
file { "$name.conf": |
125 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
126 |
ensure => "present", |
127 |
owner => root, |
128 |
group => root, |
129 |
mode => 644, |
130 |
notify => Service['apache'], |
131 |
content => template("apache/vhost_django_app.conf") |
132 |
} |
133 |
|
134 |
# fichier django wsgi |
135 |
file { "$name.wsgi": |
136 |
path => "/usr/local/lib/wsgi/$name.wsgi", |
137 |
ensure => "present", |
138 |
owner => root, |
139 |
group => root, |
140 |
mode => 755, |
141 |
notify => Service['apache'], |
142 |
content => template("apache/django.wsgi") |
143 |
} |
144 |
} |
145 |
|
146 |
define vhost_other_app($vhost_file) { |
147 |
include apache::base |
148 |
file { "$name.conf": |
149 |
path => "/etc/httpd/conf/vhosts.d/$name.conf", |
150 |
ensure => "present", |
151 |
owner => root, |
152 |
group => root, |
153 |
mode => 644, |
154 |
notify => Service['apache'], |
155 |
content => template($vhost_file) |
156 |
} |
157 |
} |
158 |
|
159 |
define webapp_other($webapp_file) { |
160 |
include apache::base |
161 |
$webappname = $name |
162 |
file { "webapp_$name.conf": |
163 |
path => "/etc/httpd/conf/webapps.d/$webappname.conf", |
164 |
ensure => "present", |
165 |
owner => root, |
166 |
group => root, |
167 |
mode => 644, |
168 |
notify => Service['apache'], |
169 |
content => template($webapp_file) |
170 |
} |
171 |
} |
172 |
} |