|
14 | 14 | # } |
15 | 15 | # } |
16 | 16 | # |
17 | | -# @param keyring_dir |
| 17 | +# @param dir |
18 | 18 | # Path to the directory where the keyring will be stored. |
19 | 19 | # |
20 | | -# @param keyring_filename |
| 20 | +# @param filename |
21 | 21 | # Optional filename for the keyring. It should also contain extension along with the filename. |
22 | 22 | # |
23 | | -# @param keyring_file |
24 | | -# File path of the keyring. |
25 | | -# |
26 | | -# @param keyring_file_mode |
| 23 | +# @param mode |
27 | 24 | # File permissions of the keyring. |
28 | 25 | # |
29 | 26 | # @param source |
|
36 | 33 | # Ensure presence or absence of the resource. |
37 | 34 | # |
38 | 35 | define apt::keyring ( |
39 | | - Stdlib::Absolutepath $keyring_dir = '/etc/apt/keyrings', |
40 | | - String[1] $keyring_filename = $name, |
41 | | - Stdlib::Absolutepath $keyring_file = "${keyring_dir}/${keyring_filename}", |
42 | | - Stdlib::Filemode $keyring_file_mode = '0644', |
| 36 | + Stdlib::Absolutepath $dir = '/etc/apt/keyrings', |
| 37 | + String[1] $filename = $name, |
| 38 | + Stdlib::Filemode $mode = '0644', |
43 | 39 | Optional[Stdlib::Filesource] $source = undef, |
44 | 40 | Optional[String[1]] $content = undef, |
45 | 41 | Enum['present','absent'] $ensure = 'present', |
46 | 42 | ) { |
47 | | - ensure_resource('file', $keyring_dir, { ensure => 'directory', mode => '0755', }) |
| 43 | + ensure_resource('file', $dir, { ensure => 'directory', mode => '0755', }) |
48 | 44 | if $source and $content { |
49 | 45 | fail("Parameters 'source' and 'content' are mutually exclusive") |
50 | 46 | } elsif ! $source and ! $content { |
51 | 47 | fail("One of 'source' or 'content' parameters are required") |
52 | 48 | } |
53 | 49 |
|
| 50 | + $file = "${dir}/${filename}" |
| 51 | + |
54 | 52 | case $ensure { |
55 | 53 | 'present': { |
56 | | - file { $keyring_file: |
| 54 | + file { $file: |
57 | 55 | ensure => 'file', |
58 | | - mode => $keyring_file_mode, |
| 56 | + mode => $mode, |
59 | 57 | owner => 'root', |
60 | 58 | group => 'root', |
61 | 59 | source => $source, |
62 | 60 | content => $content, |
63 | 61 | } |
64 | 62 | } |
65 | 63 | 'absent': { |
66 | | - file { $keyring_file: |
| 64 | + file { $file: |
67 | 65 | ensure => $ensure, |
68 | 66 | } |
69 | 67 | } |
|
0 commit comments