annotate modules/apt/manifests/key.pp @ 482:d83de9b3a62b default tip

Update hiera.yaml within Puppet config Forgot that we manage it from here. Now has content to match new packages
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Aug 2024 16:10:36 +0100
parents adf6fe9bbc17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 # @summary Manages the GPG keys that Apt uses to authenticate packages.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 # @note
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 # The apt::key defined type makes use of the apt_key type, but includes extra functionality to help prevent duplicate keys.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 # @example Declare Apt key for apt.puppetlabs.com source
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 # apt::key { 'puppetlabs':
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 # id => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 # server => 'keyserver.ubuntu.com',
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 # options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"',
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 # }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 # @param id
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 # Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 # characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters).
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 # @param ensure
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 # Specifies whether the key should exist. Valid options: 'present', 'absent' or 'refreshed'. Using 'refreshed' will make keys auto
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 # update when they have expired (assuming a new key exists on the key server).
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 # @param content
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 # 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.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 # @param source
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 # Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 # an absolute path.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 # @param server
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 # Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 # hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 # @param weak_ssl
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 # Specifies whether strict SSL verification on a https URL should be disabled. Valid options: true or false.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 # @param options
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 # Passes additional options to `apt-key adv --keyserver-options`.
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 #
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 define apt::key (
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 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,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 Enum['present', 'absent', 'refreshed'] $ensure = present,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 Optional[String] $content = undef,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef,
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
43 Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$/] $server = $apt::keyserver,
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 Boolean $weak_ssl = false,
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
45 Optional[String] $options = $apt::key_options,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
46 ) {
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 case $ensure {
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 /^(refreshed|present)$/: {
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
49 if defined(Anchor["apt_key ${id} absent"]) {
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 fail("key with id ${id} already ensured as absent")
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 if !defined(Anchor["apt_key ${id} present"]) {
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 apt_key { $title:
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 ensure => present,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 refresh => $ensure == 'refreshed',
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 id => $id,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 source => $source,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 content => $content,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 server => $server,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 weak_ssl => $weak_ssl,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 options => $options,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 } -> anchor { "apt_key ${id} present": }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 case $facts['os']['name'] {
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 'Debian': {
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
67 stdlib::ensure_packages(['gnupg'])
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
68 Apt::Key<| title == $title |>
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 'Ubuntu': {
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
71 stdlib::ensure_packages(['gnupg'])
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
72 Apt::Key<| title == $title |>
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
74 default: {
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
75 # Nothing in here
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
76 }
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
81 /^absent$/: {
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
82 if defined(Anchor["apt_key ${id} present"]) {
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 fail("key with id ${id} already ensured as present")
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 386
diff changeset
86 if !defined(Anchor["apt_key ${id} absent"]) {
386
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 apt_key { $title:
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 ensure => $ensure,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 id => $id,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 source => $source,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 content => $content,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 server => $server,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 weak_ssl => $weak_ssl,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 options => $options,
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 } -> anchor { "apt_key ${id} absent": }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 default: {
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 fail("Invalid \'ensure\' value \'${ensure}\' for apt::key")
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 }
3fce34f642f1 Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 }