Puppet Class: puppetmaster::gitsync

Defined in:
modules/puppetmaster/manifests/gitsync.pp

Summary

Sync local operations/puppet.git checkout with upstream.

Overview

Parameters:

  • run_every_minutes (Integer) (defaults to: 10)

    how often to run the systemd timer

  • private_only (Boolean) (defaults to: false)

    only sync the private repo

  • prometheus_file (Stdlib::Unixpath) (defaults to: '/var/lib/prometheus/node.d/puppet-gitsync.prom')

    location of the prometheus file

  • base_dir (Stdlib::Unixpath) (defaults to: '/var/lib/git')

    the base_dir of git repos

  • git_user (String[1]) (defaults to: 'root')

    the user that owns the git repo



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
# File 'modules/puppetmaster/manifests/gitsync.pp', line 7

class puppetmaster::gitsync (
    Integer          $run_every_minutes = 10,
    Boolean          $private_only      = false,
    Stdlib::Unixpath $prometheus_file   = '/var/lib/prometheus/node.d/puppet-gitsync.prom',
    Stdlib::Unixpath $base_dir          = '/var/lib/git',
    String[1]        $git_user          = 'root',
) {
    ensure_packages([
        'python3-git',
        'python3-prometheus-client',
        'python3-requests',
    ])

    file { '/usr/local/bin/git-sync-upstream':
        ensure => file,
        source => 'puppet:///modules/puppetmaster/git-sync-upstream.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    $private_arg = $private_only.bool2str('--private-only', '')
    $command = @("COMMAND"/L)
        /usr/local/bin/git-sync-upstream --prometheus-file ${prometheus_file} \
        --base-dir ${base_dir} \
        --git-user ${git_user} \
        ${private_arg}
        |- COMMAND

    systemd::timer::job { 'puppet-git-sync-upstream':
        ensure      => 'present',
        user        => 'root',
        description => 'Update local Puppet repository copies',
        command     => $command,
        interval    => {
            'start'    => 'OnUnitInactiveSec',
            'interval' => "${run_every_minutes}m",
        },
    }
}