|
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 | | -# you can also override the path using the `file_path` parameter. |
| 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 | | - $filename = ".netrc", |
25 | | - $file_path = "$home_base_directory/$user/$filename", |
| 21 | + Enum["present", "absent"] $ensure = "present", |
| 22 | + Stdlib::Absolutepath $home_base_directory = "/home", |
| 23 | + String $user, |
| 24 | + String $filename = ".netrc", |
| 25 | + Optional[Stdlib::Abolutepath] $file_path = "$home_base_directory/$user/$filename", |
26 | 26 | $machine_user_password_triples) { |
27 | 27 |
|
| 28 | +$real_file_path = $file_path ? { |
| 29 | + undef => "$home_base_directory/$user/$filename", |
| 30 | + default => $file_path |
| 31 | + } |
28 | 32 |
|
29 | | - file { "$file_path": |
| 33 | + file { "$real_file_path": |
30 | 34 | ensure => $ensure, |
31 | 35 | content => template('netrc/netrc.erb'), |
32 | 36 | mode => '0600', |
|
0 commit comments