forked from vStone/puppet-apache
/
listen.pp
70 lines (62 loc) · 1.54 KB
/
listen.pp
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
# = Definition: apache::listen
#
# Instruct apache to listen to this port. Name and port are
# from the defined title
#
# == Parameters:
#
# $comment:
# Additional content that gets added to the listen definition file.
#
# $name:
# Either a single port number or <ip>_<port>
#
# == Example:
#
# apache::listen { '10.0.0.1_80': }
# apache::listen { '80': }
#
define apache::listen (
$comment = ''
) {
## Requirements
require apache::params
require apache::setup::listen
####################################
#### Variable checks & Defaults ####
####################################
case $name {
/^[0-9]+$/: {
$do_file = true
$listen_ip = ''
$listen_port = $name
}
/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)_([0-9]+)/: {
$listen_ip = $1
$listen_port = $2
if defined(Apache::Listen[$listen_port]) {
$do_file = false
notify {"apache-listen-allinterfaces-warning-${name}":
message => template('apache/msg/listen-allinterfaces-warning.erb'),
}
} else {
$do_file = true
}
}
default : {
$failmsg = template('apache/msg/listen-fail-ip-port-fromname.erb')
fail ($failmsg)
}
}
####################################
#### Prepare content ####
####################################
if $do_file {
## Filename for thingie.
$fname = "listen_${listen_ip}_${listen_port}"
apache::confd::file {$fname:
confd => $apache::setup::listen::confd,
content => template('apache/confd/listen.erb'),
}
}
}