Skip to content

Commit 2084b16

Browse files
author
shimon
committed
support overwrites of params
1 parent db3fa38 commit 2084b16

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

manifests/init.pp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,32 @@
55
# Parameters: $user is the useraccount on the machine for which the netrc shall be configured,
66
# $machine_user_password_triples is an array of arrays containing three string params: machine, user, password
77
# $root_home_directory (optional) is the directory where all user homes are located on the target machine, default value is "/home"
8-
#
8+
# $file_path (optional) is the absolute path of the .netrc file.
99
# Actions:
1010
#
1111
# Requires:
1212
#
1313
# Sample Usage: netrc::foruser("netrc_myuser": user => 'myuser', machine_user_password_triples => [['myserver.localdomain','myuser','pw'],['mysecondserver.localdomain','myuser','pw2']])
14-
#
14+
# you can also override the full path by using the `file_path` parameter.
1515
# [Remember: No empty lines between comments and class definition]
1616
class netrc {
1717

1818
}
1919

2020
define netrc::foruser(
21-
Enum["present", "absent"] $ensure = "present",
22-
$home_base_directory = "/home",
23-
$user,
24-
$machine_user_password_triples) {
25-
26-
$filename = ".netrc"
21+
Enum["present", "absent"] $ensure = "present",
22+
Stdlib::Absolutepath $home_base_directory = "/home",
23+
String $user,
24+
String $filename = ".netrc",
25+
Stdlib::Absolutepath $file_path = "$home_base_directory/$user/$filename",
26+
Array[Hash] $machine_user_password_triples) {
2727

28-
file { "$home_base_directory/$user/$filename":
29-
ensure => $ensure,
30-
content => template('netrc/netrc.erb'),
31-
mode => '0600',
32-
owner => "$user"
28+
file { $file_path:
29+
ensure => $ensure,
30+
content => epp('netrc/netrc.epp', {
31+
machine_user_password_triples => $machine_user_password_triples
32+
}),
33+
mode => '0600',
34+
owner => "$user"
3335
}
3436
}

templates/netrc.epp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% $machine_user_password_triples.each |$key, $value| { -%>
2+
machine <%= $value['machine'] %> login <%= $value['login'] %> password <%= $value['password'] %>
3+
<%- } -%>

templates/netrc.erb

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)