This repository was archived by the owner on Jun 11, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +91
-1
lines changed Expand file tree Collapse file tree 4 files changed +91
-1
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ source 'https://github.com/example42/puppet-git'
7
7
summary ' Puppet module for git'
8
8
description ' This module installs and manages git. Check README for details.'
9
9
dependency ' example42/puppi' , ' >= 2.0.0'
10
+ dependency ' puppetlabs-stdlib' , ' >=4.1.0'
10
11
# dependency 'example42/monitor', '>= 2.0.0'
11
12
# dependency 'example42/firewall', '>= 2.0.0'
Original file line number Diff line number Diff line change
1
+ # = Define: git::clone
2
+ #
3
+ # Clone a git repository if it does not exist yet. Will not do anything
4
+ # if the clone already exists.
5
+ #
6
+ # == Parameters
7
+ #
8
+ # [*ensure*]
9
+ # Define if the git_reposync script and eventual cron job
10
+ # must be present or absent. Default: present.
11
+ #
12
+ # [*source_url*]
13
+ # Url of the repository to use. As passed to the git command. Required.
14
+ #
15
+ # [*destination_dir*]
16
+ # Local directory where to clone the repository. Required.
17
+ #
18
+ # [*creates*]
19
+ # Path of a file or directory created by the git command. If it
20
+ # exists Puppet will not clone the repo.
21
+ # Default: $destination_dir.
22
+ #
23
+ # [*extra_options*]
24
+ # Optional extra options to add to git command. Default: ''.
25
+ #
26
+ # [*branch*]
27
+ # Optional branch name
28
+ #
29
+ # [*owner*]
30
+ # Owner of the cloned repo.
31
+ #
32
+ define git::clone (
33
+ $ensure = ' present' ,
34
+ $source_url ,
35
+ $destination_dir ,
36
+ $creates = $destination_dir,
37
+ $extra_options = ' ' ,
38
+ $branch = $git::default_branch,
39
+ $owner = $git::default_owner,) {
40
+ include git
41
+
42
+ validate_string($owner )
43
+ validate_string($branch )
44
+
45
+ case $ensure {
46
+ ' present' : {
47
+ exec { "git-clone-${name}" :
48
+ command => " git clone --recursive ${source_url} -b ${branch} ${extra_options} ${destination_dir} " ,
49
+ path => ' /usr/bin' ,
50
+ creates => $creates ,
51
+ user => $owner ,
52
+ }
53
+ }
54
+ ' absent' : {
55
+ file { "${destination_dir}" :
56
+ ensure => ' absent' ,
57
+ recurse => true ,
58
+ force => true ,
59
+ }
60
+ }
61
+ default : {
62
+ fail(" git::clone only supports 'present' and 'absent', '${ensure} ' is unknown.'" )
63
+ }
64
+ }
65
+
66
+ }
Original file line number Diff line number Diff line change 62
62
# [*config_file*]
63
63
# Main configuration file path
64
64
#
65
+ # [*default_owner*]
66
+ # Owner of the repositories cloned via git::clone. Use this if most of the
67
+ # repositories you clone should belong to the same user.
68
+ # Default: root
69
+ #
70
+ # [*default_branch*]
71
+ # Branch on which to execute operations. In most cases 'master' is what you
72
+ # want, but if most of your repos should use another branch, use this
73
+ # parameter to set the default.
74
+ # Default: master
75
+ #
76
+ # [*clones*]
77
+ # A hash describing a list of repo to clone.
78
+ # Default: {}
79
+ #
65
80
# == Examples
66
81
#
67
82
# You can use this class in 2 ways:
81
96
$audit_only = params_lookup( ' audit_only' , ' global' ),
82
97
$noops = params_lookup( ' noops' ),
83
98
$package = params_lookup( ' package' ),
84
- $config_file = params_lookup( ' config_file' )
99
+ $config_file = params_lookup( ' config_file' ),
100
+ $default_owner = params_lookup( ' default_owner' ),
101
+ $default_branch = params_lookup( ' default_branch' ),
102
+ $clones = params_lookup( ' clones' ),
85
103
) inherits git::params {
86
104
87
105
$config_file_mode =$git::params::config_file_mode
152
170
include $git::my_class
153
171
}
154
172
173
+ create_resources(' git::clone' , $clones )
155
174
}
Original file line number Diff line number Diff line change 36
36
default => ' root' ,
37
37
}
38
38
39
+ $default_owner = ' root'
40
+ $default_branch = ' master'
41
+ $clones = {}
42
+
39
43
# General Settings
40
44
$my_class = ' '
41
45
$source = ' '
You can’t perform that action at this time.
0 commit comments