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 +keyserver.ubuntu.com+.
50 # Additional options to pass on to `apt-key adv --keyserver-options`.
56 $server = $::apt::keyserver,
60 validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
61 validate_re($ensure, ['\Aabsent|present\Z',])
64 validate_string($content)
68 validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
72 validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
76 validate_string($options)
81 if defined(Anchor["apt_key ${id} absent"]){
82 fail("key with id ${id} already ensured as absent")
85 if !defined(Anchor["apt_key ${id} present"]) {
94 anchor { "apt_key ${id} present": }
99 if defined(Anchor["apt_key ${id} present"]){
100 fail("key with id ${id} already ensured as present")
103 if !defined(Anchor["apt_key ${id} absent"]){
112 anchor { "apt_key ${id} absent": }
117 fail "Invalid 'ensure' value '${ensure}' for apt::key"