File: server.pp

package info (click to toggle)
puppet-module-puppetlabs-rsync 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: ruby: 679; sh: 10; makefile: 4
file content (86 lines) | stat: -rw-r--r-- 2,751 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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
#
class rsync::server(
  Boolean                                    $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                                               = {},
  Optional[String[1]]                      $package_name = undef,
  String[1]                                   $conf_file = '/etc/rsync.conf',
  String[1]                                 $servicename = 'rsync',
  Stdlib::Ensure::Service                $service_ensure = 'running',
  Variant[Boolean, Enum['mask']]         $service_enable = true,
  Boolean                                $manage_package = $rsync::manage_package,
) inherits 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 {

    # Manage the installation of the rsyncd package?
    if $manage_package {

      # RHEL8 and newer (and their variants) have a separate package for rsyncd daemon.  If the $package_name
      # variable is defined (the variable is defined in the hiera hierarchy), then install the package.
      if $package_name {
        package {$package_name:
          ensure => $rsync::package_ensure,
          notify => Service[$servicename],
        }
      }
    }

    service { $servicename:
      ensure     => $service_ensure,
      enable     => $service_enable,
      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)

}