This repository was archived by the owner on Jun 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathclone.pp
More file actions
67 lines (63 loc) · 1.59 KB
/
clone.pp
File metadata and controls
67 lines (63 loc) · 1.59 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# = Define: git::clone
#
# Clone a git repository if it does not exist yet. Will not do anything
# if the clone already exists.
#
# == Parameters
#
# [*ensure*]
# Define if the git_reposync script and eventual cron job
# must be present or absent. Default: present.
#
# [*source_url*]
# Url of the repository to use. As passed to the git command. Required.
#
# [*destination_dir*]
# Local directory where to clone the repository. Required.
#
# [*creates*]
# Path of a file or directory created by the git command. If it
# exists Puppet will not clone the repo.
# Default: $destination_dir.
#
# [*extra_options*]
# Optional extra options to add to git command. Default: ''.
#
# [*branch*]
# Optional branch name
#
# [*owner*]
# Owner of the cloned repo.
#
define git::clone (
$source_url,
$destination_dir,
$ensure = 'present',
$creates = $destination_dir,
$extra_options = '',
$branch = $git::default_branch,
$owner = $git::default_owner,) {
include git
validate_string($owner)
validate_string($branch)
case $ensure {
'present' : {
exec { "git-clone-${name}":
command => "git clone --recursive ${source_url} -b ${branch} ${extra_options} ${destination_dir}",
path => '/usr/bin:/opt/csw/bin',
creates => $creates,
user => $owner,
}
}
'absent' : {
file { $destination_dir:
ensure => 'absent',
recurse => true,
force => true,
}
}
default : {
fail("git::clone only supports 'present' and 'absent', '${ensure}' is unknown.'")
}
}
}