aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/manifests/snapshot.pp
blob: 06473efe6c0531d490d28ec677159b6e5c039eaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
define git::snapshot( $source,
                      $refresh = '*/5',
                      $user = 'root',
                      $branch = 'master') {
    include git::client
    #TODO
    # should handle branch -> clone -n + branch + checkout
    # create a script
    # Ideally, should be handled by vcsrepo
    # https://github.com/bruce/puppet-vcsrepo
    # once it is merged in puppet
    exec { "/usr/bin/git clone -b ${branch} ${source} ${name}":
        creates => $name,
        user    => $user
    }

    if ($refresh != '0') {
        cron { "update ${name}":
            command => "cd ${name} && /usr/bin/git pull -q && /usr/bin/git submodule --quiet update --init --recursive",
            user    => $user,
            minute  => $refresh
        }
    }
}