Puppet Class: aptrepo::rsync

Defined in:
modules/aptrepo/manifests/rsync.pp

Overview

sets up rsync of APT repos between 2 servers activates rsync for push from the primary to secondary

Parameters:

  • primary_server (Any)
  • secondary_servers (Any)


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

class aptrepo::rsync (
    $primary_server,
    $secondary_servers,
){
    # only activate rsync/firewall hole on the server that is NOT active
    if $facts['fqdn'] == $primary_server {

        $ensure_ferm = 'absent'
        $ensure_job = 'present'
        $ensure_sync = 'absent'

    } else {

        $ensure_ferm = 'present'
        $ensure_job = 'absent'
        $ensure_sync = 'present'

        include rsync::server
        include aptrepo::rsync

        rsync::server::module { 'install-srv':
            ensure         => $aptrepo::rsync::ensure,
            path           => '/srv',
            read_only      => 'no',
            hosts_allow    => [$primary_server],
            auto_ferm      => true,
            auto_ferm_ipv6 => true,
        }

        rsync::server::module { 'install-home':
            ensure         => $aptrepo::rsync::ensure,
            path           => '/home',
            read_only      => 'no',
            hosts_allow    => [$primary_server],
            auto_ferm      => true,
            auto_ferm_ipv6 => true,
        }
    }

    $secondary_servers.each |String $secondary_server| {
        systemd::timer::job { "rsync-aptrepo-${secondary_server}":
            ensure      => $ensure_job,
            user        => 'root',
            description => 'rsync APT repo data from the primary to a secondary server',
            command     => "/usr/bin/rsync -avp --delete /srv/ rsync://${secondary_server}/install-srv",
            interval    => {'start' => 'OnUnitInactiveSec', 'interval' => '6h'},
        }
    }
}