fermport for xinetd::service
[mirror/dsa-puppet.git] / modules / xinetd / manifests / service.pp
1 define xinetd::service (
2         $id,
3         $server,
4         $service,
5         $port='',
6         $bind='',
7         $type='',
8         $socket_type=stream,
9         $protocol=tcp,
10         $flags='',
11         $wait=no,
12         $user=root,
13         $group='',
14         $server_args='',
15         $nice=10,
16         $instances=100,
17         $per_source=3,
18         $cps='0 0',
19         $ensure=present,
20         $ferm=true
21 ) {
22         include xinetd
23
24         case $ensure {
25                 present,absent,file: {}
26                 default: { fail("Invalid ensure for '$name'") }
27         }
28
29         if $ferm {
30                 $fermport = $port ? {
31                         "" => $service,
32                         default => $port
33                 }
34
35                 @ferm::rule { "dsa-xinetd-${name}":
36                         description => "Allow traffic to ${service}",
37                         rule        => "&SERVICE(${protocol}, ${fermport})"
38                 }
39         }
40
41         file { "/etc/xinetd.d/${name}":
42                 ensure  => $ensure,
43                 content => template('xinetd/service.erb'),
44                 notify  => Service['xinetd'],
45                 require => Package['xinetd'],
46         }
47 }