This repository has been archived by the owner on Oct 28, 2022. It is now read-only.
forked from edestecd/puppet-software
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.pp
144 lines (121 loc) · 3.56 KB
/
git.pp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# git.pp
# Install git cli, optional tab completion, config and ignore files
#
class software::vcsscm::git (
$ensure = $software::params::software_ensure,
$gui = false,
$bash_completion = false,
$bash_prompt = false,
$gitconfig = false,
$gitignore = false,
) inherits software::params {
validate_string($ensure)
case $::operatingsystem {
'Ubuntu': {
package { 'git':
ensure => $ensure,
}
if $gui {
package { ['gitk', 'git-gui']:
ensure => $ensure,
}
}
if $bash_completion {
package { 'bash-completion':
ensure => $ensure,
}
}
if $bash_prompt {
vcsrepo { '/opt/bash-git-prompt/':
ensure => present,
provider => git,
source => 'https://github.com/magicmonty/bash-git-prompt.git',
depth => 1,
}
file { '/etc/bash_completion.d/bash-git-prompt':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/software/vcsscm/git/bash-git-prompt',
}
}
if $gitconfig or $gitignore {
if !defined(File['/etc/skel/.config']) {
file { '/etc/skel/.config':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
}
if !defined(File['/etc/skel/.config/git']) {
file { '/etc/skel/.config/git':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
}
}
if $gitconfig {
$gitconfig_system = $gitconfig ? {
Boolean => 'puppet:///modules/software/vcsscm/git/system-gitconfig',
String => false, # a string will only set user config
Hash => $gitconfig['system'],
default => fail('$gitconfig must be one of (Boolean, String, Hash)'),
}
if $gitconfig_system {
file { '/etc/gitconfig':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => $gitconfig_system,
}
}
$gitconfig_user = $gitconfig ? {
Boolean => 'puppet:///modules/software/vcsscm/git/user-gitconfig',
String => $gitconfig,
Hash => $gitconfig['user'],
default => fail('$gitconfig must be one of (Boolean, String, Hash)'),
}
if $gitconfig_user {
file { '/etc/skel/.config/git/config':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => $gitconfig_user,
}
}
}
if $gitignore {
$gitignore_user = $gitignore ? {
Boolean => 'puppet:///modules/software/vcsscm/git/user-gitignore',
String => $gitignore,
Hash => $gitignore['user'],
default => fail('$gitignore must be one of (Boolean, String, Hash)'),
}
if $gitignore_user {
file { '/etc/skel/.config/git/ignore':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => $gitignore_user,
}
}
}
}
'windows': {
package { 'git':
ensure => $ensure,
provider => chocolatey,
}
}
default: {
fail("The ${name} class is not supported on ${::operatingsystem}.")
}
}
}