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 or full key fingerprint. This value is validated with
14 # a regex enforcing it to only contain valid hexadecimal characters, be
15 # precisely 8 or 16 hexadecimal characters long and optionally prefixed
16 # with 0x for key IDs, or 40 hexadecimal characters long for key
20 # _default_: +present+
22 # The state we want this key in, may be either one of:
29 # This parameter can be used to pass in a GPG key as a
30 # string in case it cannot be fetched from a remote location
31 # and using a file resource is for other reasons inconvenient.
36 # This parameter can be used to pass in the location of a GPG
37 # key. This URI can take the form of a:
38 # * +URL+: ftp, http or https
39 # * +path+: absolute path to a file on the target system.
44 # The keyserver from where to fetch our GPG key. It can either be a domain
45 # name or url. It defaults to
46 # undef which results in apt_key's default keyserver being used,
47 # currently +keyserver.ubuntu.com+.
52 # Additional options to pass on to `apt-key adv --keyserver-options`.
62 validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
63 validate_re($ensure, ['\Aabsent|present\Z',])
66 validate_string($key_content)
70 validate_re($key_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
74 validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
78 validate_string($key_options)
83 if defined(Anchor["apt_key ${key} absent"]){
84 fail("key with id ${key} already ensured as absent")
87 if !defined(Anchor["apt_key ${key} present"]) {
91 source => $key_source,
92 content => $key_content,
93 server => $key_server,
94 keyserver_options => $key_options,
96 anchor { "apt_key ${key} present": }
101 if defined(Anchor["apt_key ${key} present"]){
102 fail("key with id ${key} already ensured as present")
105 if !defined(Anchor["apt_key ${key} absent"]){
109 source => $key_source,
110 content => $key_content,
111 server => $key_server,
112 keyserver_options => $key_options,
114 anchor { "apt_key ${key} absent": }
119 fail "Invalid 'ensure' value '${ensure}' for apt::key"