This repository was archived by the owner on Jun 22, 2022. It is now read-only.
forked from voxpupuli/puppet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotfile.pp
More file actions
49 lines (47 loc) · 1.42 KB
/
dotfile.pp
File metadata and controls
49 lines (47 loc) · 1.42 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
#
# @summary Manages any python dotfiles with a simple config hash.
#
# @param ensure
# @param filename Filename.
# @param mode File mode.
# @param owner user owner of dotfile
# @param group group owner of dotfile
# @param config Config hash. This will be expanded to an ini-file.
#
# @example Create a pip config in /var/lib/jenkins/.pip/
# python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
# ensure => present,
# owner => 'jenkins',
# group => 'jenkins',
# config => {
# 'global' => {
# 'index-url' => 'https://mypypi.acme.com/simple/'
# 'extra-index-url' => 'https://pypi.risedev.at/simple/'
# }
# }
# }
#
#
define python::dotfile (
Enum['absent', 'present'] $ensure = 'present',
String[1] $filename = $title,
String[1] $owner = 'root',
String[1] $group = 'root',
Stdlib::Filemode $mode = '0644',
Hash $config = {},
) {
$parent_dir = dirname($filename)
exec { "create ${title}'s parent dir":
command => "install -o ${owner} -g ${group} -d ${parent_dir}",
path => [ '/usr/bin', '/bin', '/usr/local/bin', ],
creates => $parent_dir,
}
file { $filename:
ensure => $ensure,
owner => $owner,
group => $group,
mode => $mode,
content => template("${module_name}/inifile.erb"),
require => Exec["create ${title}'s parent dir"],
}
}