Puppet Class: rsync::server

Inherits:
rsync
Defined in:
modules/rsync/manifests/server.pp

Overview

Parameters:

  • address (Any) (defaults to: '0.0.0.0')
  • timeout (Any) (defaults to: '300')
  • motd_file (Any) (defaults to: 'UNSET')
  • log_file (Any) (defaults to: 'UNSET')
  • use_chroot (Any) (defaults to: 'yes')
  • use_ipv6 (Any) (defaults to: false)
  • rsync_opts (Any) (defaults to: [])
  • rsyncd_conf (Any) (defaults to: {})


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
# File 'modules/rsync/manifests/server.pp', line 13

class rsync::server(
  $address    = '0.0.0.0',
  $timeout    = '300',
  $motd_file  = 'UNSET',
  $log_file   = 'UNSET',
  $use_chroot = 'yes',
  $use_ipv6   = false,
  $rsync_opts = [],
  $rsyncd_conf = {},
) inherits rsync {

  $rsync_fragments = '/etc/rsync.d'
  $rsync_conf      = '/etc/rsyncd.conf'
  $rsync_pid       = '/var/run/rsync.pid'

  # rsync daemon defaults file
  file { '/etc/default/rsync':
    ensure  => present,
    mode    => '0444',
    owner   => 'root',
    group   => 'root',
    content => template('rsync/rsync.default.erb'),
  }

  if($use_ipv6) {
      # If address is left blank, rsync will listen
      #  on :::873 in addition to 0.0.0.0:873.
      $address = ''
  }

  service { 'rsync':
      ensure    => running,
      enable    => true,
      subscribe => [ Exec['compile fragments'], File['/etc/default/rsync'] ],
  }

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

  file { $rsync_fragments:
    ensure  => directory,
    recurse => true,
    purge   => true,
  }

  file { "${rsync_fragments}/header":
    content => template('rsync/header.erb'),
  }

  # perhaps this should be a script
  # this allows you to only have a header and no fragments, which happens
  # by default if you have an rsync::server but not an rsync::repo on a host
  # which happens with cobbler systems by default
  exec { 'compile fragments':
    refreshonly => true,
    command     => "ls ${rsync_fragments}/frag-* 1>/dev/null 2>/dev/null && if [ $? -eq 0 ]; then cat ${rsync_fragments}/header ${rsync_fragments}/frag-* > ${rsync_conf}; else cat ${rsync_fragments}/header > ${rsync_conf}; fi; $(exit 0)",
    subscribe   => File["${rsync_fragments}/header"],
    path        => '/bin:/usr/bin',
  }
}