Puppet Class: puppetmaster::gitsync

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

Overview

Class: puppetmaster::gitsync

Sync local operations/puppet.git checkout with upstream.

Parameters:

  • run_every_minutes (Any) (defaults to: '10')
  • private_only (Any) (defaults to: false)


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

class puppetmaster::gitsync(
    $run_every_minutes = '10',
    $private_only = false,
) {

    ensure_packages([
        'python3-git',
        'python3-requests',
        ])


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

    if ($private_only) {
        cron { 'rebase_labs_private_puppet':
            ensure  => present,
            user    => 'root',
            minute  => "*/${run_every_minutes}",
            command => '/usr/local/bin/git-sync-upstream --private-only >>/var/log/git-sync-upstream.log 2>&1',
            require => File['/usr/local/bin/git-sync-upstream'],
        }
    } else {
        cron { 'rebase_operations_puppet':
            ensure  => present,
            user    => 'root',
            minute  => "*/${run_every_minutes}",
            command => '/usr/local/bin/git-sync-upstream >>/var/log/git-sync-upstream.log 2>&1',
            require => File['/usr/local/bin/git-sync-upstream'],
        }
    }

    logrotate::conf { 'git-sync-upstream':
        ensure => present,
        source => 'puppet:///modules/puppetmaster/git-sync-upstream.logrotate',
    }

    sudo::user { 'cherry_pick_count':
        ensure     => present,
        user       => 'diamond',
        privileges => [ 'ALL = (root) NOPASSWD: /usr/bin/git --git-dir=/var/lib/git/operations/puppet/.git log --pretty=oneline --abbrev-commit origin/HEAD..HEAD' ],
    }

    diamond::collector { 'CherryPickCounter':
        ensure  => present,
        source  => 'puppet:///modules/puppetmaster/cherry-pick-counter-collector.py',
        require => Sudo::User['cherry_pick_count'],
    }
}