3 # The apt::key defined type allows for keys to be added to apt's keyring
4 # which is used for package validation. This defined type uses the apt_key
5 # native type to manage keys. This is a simple wrapper around apt_key with
6 # a few safeguards in place.
11 # _default_: +$title+, the title/name of the resource
13 # Is a GPG key ID. This key ID is validated with a regex enforcing it
14 # to only contain valid hexadecimal characters, be precisely 8 or 16
15 # characters long and optionally prefixed with 0x.
18 # _default_: +present+
20 # The state we want this key in, may be either one of:
27 # This parameter can be used to pass in a GPG key as a
28 # string in case it cannot be fetched from a remote location
29 # and using a file resource is for other reasons inconvenient.
34 # This parameter can be used to pass in the location of a GPG
35 # key. This URI can take the form of a:
36 # * +URL+: ftp, http or https
37 # * +path+: absolute path to a file on the target system.
42 # The keyserver from where to fetch our GPG key. It defaults to
43 # undef which results in apt_key's default keyserver being used,
44 # currently +keyserver.ubuntu.com+.
49 # Additional options to pass on to `apt-key adv --keyserver-options`.
59 validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z'])
60 validate_re($ensure, ['\Aabsent|present\Z',])
63 validate_string($key_content)
67 validate_re($key_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
71 if !is_domain_name($key_server) {
72 fail('$key_server must be a valid domain name')
77 validate_string($key_options)
82 if defined(Anchor["apt_key ${key} absent"]){
83 fail("key with id ${key} already ensured as absent")
86 if !defined(Anchor["apt_key ${key} present"]) {
90 source => $key_source,
91 content => $key_content,
92 server => $key_server,
93 keyserver_options => $key_options,
95 anchor { "apt_key ${key} present": }
100 if defined(Anchor["apt_key ${key} present"]){
101 fail("key with id ${key} already ensured as present")
104 if !defined(Anchor["apt_key ${key} absent"]){
108 source => $key_source,
109 content => $key_content,
110 server => $key_server,
111 keyserver_options => $key_options,
113 anchor { "apt_key ${key} absent": }
118 fail "Invalid 'ensure' value '${ensure}' for apt::key"