Puppet Class: rsync::server

Inherits:
rsync
Defined in:
manifests/server.pp

Overview

Class: rsync::server

The rsync server. Supports both standard rsync as well as rsync over ssh

Requires:

class xinetd if use_xinetd is set to true
class rsync

Parameters:

  • use_xinetd (Any) (defaults to: true)
  • address (Any) (defaults to: '0.0.0.0')
  • motd_file (Any) (defaults to: 'UNSET')
  • pid_file (Variant[Enum['UNSET'], Stdlib::Absolutepath]) (defaults to: '/var/run/rsyncd.pid')
  • use_chroot (Any) (defaults to: 'yes')
  • uid (Any) (defaults to: 'nobody')
  • gid (Any) (defaults to: 'nobody')
  • modules (Any) (defaults to: {})


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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'manifests/server.pp', line 9

class rsync::server(
  $use_xinetd = true,
  $address    = '0.0.0.0',
  $motd_file  = 'UNSET',
  Variant[Enum['UNSET'], Stdlib::Absolutepath] $pid_file = '/var/run/rsyncd.pid',
  $use_chroot = 'yes',
  $uid        = 'nobody',
  $gid        = 'nobody',
  $modules    = {},
) inherits rsync {

  case $facts['os']['family'] {
    'Debian': {
      $conf_file = '/etc/rsyncd.conf'
      $servicename = 'rsync'
    }
    'Suse': {
      $conf_file = '/etc/rsyncd.conf'
      $servicename = 'rsyncd'
    }
    'RedHat': {
      $conf_file = '/etc/rsyncd.conf'
      $servicename = 'rsyncd'
    }
    'FreeBSD': {
      $conf_file = '/usr/local/etc/rsync/rsyncd.conf'
      $servicename = 'rsyncd'
    }
    default: {
      $conf_file = '/etc/rsync.conf'
      $servicename = 'rsync'
    }
  }

  if $use_xinetd {
    include xinetd
    xinetd::service { 'rsync':
      bind        => $address,
      port        => '873',
      server      => '/usr/bin/rsync',
      server_args => "--daemon --config ${conf_file}",
      require     => Package['rsync'],
    }
  } else {
    if ($facts['os']['family'] == 'RedHat') and
        (Integer($facts['os']['release']['major']) >= 8) and
        ($rsync::manage_package) {
      package { 'rsync-daemon':
        ensure => $rsync::package_ensure,
        notify => Service[$servicename],
      }
    }

    service { $servicename:
      ensure     => running,
      enable     => true,
      hasstatus  => true,
      hasrestart => true,
      subscribe  => Concat[$conf_file],
    }

    if ( $facts['os']['family'] == 'Debian' ) {
      file { '/etc/default/rsync':
        source => 'puppet:///modules/rsync/defaults',
        notify => Service['rsync'],
      }
    }
  }

  if $motd_file != 'UNSET' {
    file { '/etc/rsync-motd':
      source => 'puppet:///modules/rsync/motd',
    }
  }

  concat { $conf_file: }

  # Template uses:
  # - $use_chroot
  # - $address
  # - $motd_file
  concat::fragment { 'rsyncd_conf_header':
    target  => $conf_file,
    content => template('rsync/header.erb'),
    order   => '00_header',
  }

  create_resources(rsync::server::module, $modules)

}