|
5 | 5 | # Parameters: $user is the useraccount on the machine for which the netrc shall be configured, |
6 | 6 | # $machine_user_password_triples is an array of arrays containing three string params: machine, user, password |
7 | 7 | # $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. |
9 | 9 | # Actions: |
10 | 10 | # |
11 | 11 | # Requires: |
12 | 12 | # |
13 | 13 | # 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. |
15 | 15 | # [Remember: No empty lines between comments and class definition] |
16 | 16 | class netrc { |
17 | 17 |
|
18 | 18 | } |
19 | 19 |
|
20 | 20 | 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) { |
27 | 27 |
|
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" |
33 | 35 | } |
34 | 36 | } |
0 commit comments