duplicate name
[mirror/dsa-puppet.git] / modules / rsync / manifests / site.pp
1 define rsync::site (
2         $bind='',
3         $bind6='',
4         $source='',
5         $content='',
6         $fname='',
7         $max_clients=200,
8         $ensure=present
9 ){
10
11         include rsync
12
13         if ! $fname {
14                 $fname_real = "/etc/rsyncd-${name}.conf"
15         } else {
16                 $fname_real = $fname
17         }
18         case $ensure {
19                 present,absent: {}
20                 default: { fail ( "Invald ensure `${ensure}' for ${name}" ) }
21         }
22
23         if ($source and $content) {
24                 fail ( "Can't define both source and content for ${name}" )
25         }
26
27         if $source {
28                 file { $fname_real:
29                         ensure => $ensure,
30                         source => $source
31                 }
32         } elsif $content {
33                 file { $fname_real:
34                         ensure  => $ensure,
35                         content => $content,
36                 }
37         } else {
38                 fail ( "Can't find config for ${name}" )
39         }
40
41         xinetd::service { "rsync-${name}":
42                 bind        => $bind,
43                 id          => "${name}-rsync",
44                 server      => '/usr/bin/rsync',
45                 port        => 'rsync',
46                 server_args => "--daemon --config=${fname_real}",
47                 ferm        => false,
48                 instances   => $max_clients,
49                 require     => File[$fname_real]
50         }
51
52         if $bind6 != '' {
53                 if $bind == '' {
54                         fail("Cannot listen on * and a specific ipv6 address")
55                 }
56                 xinetd::service { "rsync-${name}6":
57                         bind        => $bind6,
58                         id          => "${name}-rsync6",
59                         server      => '/usr/bin/rsync',
60                         port        => 'rsync',
61                         server_args => "--daemon --config=${fname_real}",
62                         ferm        => false,
63                         instances   => $max_clients,
64                         require     => File[$fname_real]
65                 }
66         }
67
68         Service['rsync']->Service['xinetd']
69 }