summaryrefslogtreecommitdiff
path: root/manifests/clone.pp
blob: 1d6a298f985aa6b79851e31b4b63403d7b2f7a9b (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
25
26
27
28
29
30
31
32
33
34
35
36
37
define git::clone(
    $ensure = present,
    $git_repo,
    $projectroot,
    $cloneddir_user='root',
    $cloneddir_group='0',
    $cloneddir_restrict_mode=true
){
    case $ensure {
        absent: {
            exec{"rm -rf $projectroot":
                onlyif => "test -d  $projectroot",
            }
        }
        default: {
            include git
            exec {"git-clone_${name}":
                command => "git-clone --no-hardlinks ${git_repo} ${projectroot}",
                creates => "${projectroot}/.git",
                user => root,
                require => Package['git'],
                notify => Exec["git-clone-chown_${name}"],
            }
            exec {"git-clone-chown_${name}":
                command => "chown -R ${cloneddir_user}:${cloneddir_group} ${projectroot};chmod -R og-rwx ${projectroot}/.git",
                refreshonly => true
            }
            if $cloneddir_restrict_mode {
                exec {"git-clone-chmod_${name}":
                    command => "chmod -R o-rwx ${projectroot}",
                    refreshonly => true,
                    subscribe => Exec["git-clone_${name}"],
                }
            }
        }
    }
}