1 # @summary Manages the GPG keys that Apt uses to authenticate packages.
4 # The apt::key defined type makes use of the apt_key type, but includes extra functionality to help prevent duplicate keys.
6 # @example Declare Apt key for apt.puppetlabs.com source
7 # apt::key { 'puppetlabs':
8 # id => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
9 # server => 'hkps.pool.sks-keyservers.net',
10 # options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"',
14 # Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal
15 # characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters).
18 # Specifies whether the key should exist. Valid options: 'present' and 'absent'.
21 # Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient.
24 # Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or
28 # Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
32 # Passes additional options to `apt-key adv --keyserver-options`.
35 Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title,
36 Enum['present', 'absent'] $ensure = present,
37 Optional[String] $content = undef,
38 Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef,
39 Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver,
40 Optional[String] $options = undef,
45 if defined(Anchor["apt_key ${id} absent"]){
46 fail(translate('key with id %{_id} already ensured as absent'),{'_id' => id})
49 if !defined(Anchor["apt_key ${id} present"]) {
57 } -> anchor { "apt_key ${id} present": }
59 case $facts['os']['name'] {
61 if versioncmp($facts['os']['release']['major'], '9') >= 0 {
62 ensure_packages(['dirmngr'])
63 Apt::Key<| title == $title |>
67 if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
68 ensure_packages(['dirmngr'])
69 Apt::Key<| title == $title |>
78 if defined(Anchor["apt_key ${id} present"]){
79 fail(translate('key with id %{_id} already ensured as present', {'_id' => id}))
82 if !defined(Anchor["apt_key ${id} absent"]){
90 } -> anchor { "apt_key ${id} absent": }
95 fail translate('Invalid \'ensure\' value \'%{_ensure}\' for apt::key', {'_ensure' => ensure})