-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache_define2.pp
More file actions
49 lines (46 loc) · 1.66 KB
/
apache_define2.pp
File metadata and controls
49 lines (46 loc) · 1.66 KB
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
case $operatingsystem {
redhat,centos,fedora: { $web = 'httpd' }
debian,ubuntu: { $web = 'apache2' }
default: { $web = 'apache2' }
}
define apachevhost ($root, $servername){
file { $root:
ensure => 'directory',
}
file { "/etc/apache2/vhosts.d/${servername}.conf":
ensure => 'file',
content => template('apache.erb'),
}
}
class apache {
package { $web:
ensure => 'installed'
}
service { $web:
name => $web,
ensure => running,
enable => true,
hasrestart => true,
require => Package[$web],
}
apachevhost { 'myapp.example.com':
servername => 'myapp.example.com',
root => "/srv/www/html/myapp.example.com"
}
apachevhost { 'myapp1.example.com':
servername => 'myapp1.example.com',
root => "/srv/www/html/myapp1.example.com"
}
apachevhost { 'myapp2.example.com':
servername => 'myapp2.example.com',
root => "/srv/www/html/myapp2.example.com"
}
apachevhost { 'myapp3.example.com':
servername => 'myapp3.example.com',
root => "/srv/www/html/myapp3.example.com"
}
Package[$web] -> Apachevhost['myapp.example.com'] ~> Service[$web]
Package[$web] -> Apachevhost['myapp1.example.com'] ~> Service[$web]
Package[$web] -> Apachevhost['myapp2.example.com'] ~> Service[$web]
Package[$web] -> Apachevhost['myapp3.example.com'] ~> Service[$web]
}