3 Puppet::Type.newtype(:apt_key) do
5 This type provides Puppet with the capabilities to manage GPG keys needed
6 by apt to perform package validation. Apt has it's own GPG keyring that can
7 be manipulated through the `apt-key` command.
9 apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
10 source => 'http://apt.puppetlabs.com/pubkey.gpg'
15 If Puppet is given the location of a key file which looks like an absolute
16 path this type will autorequire that file.
22 if self[:content] && self[:source]
23 raise('The properties content and source are mutually exclusive.')
25 if self[:id].length < 40
26 warning('The id should be a full fingerprint (40 characters), see README.')
30 newparam(:id, namevar: true) do
31 desc 'The ID of the key you want to manage.'
32 # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's
33 # and may start with the optional 0x, or they can be 40-digit key fingerprints
34 newvalues(%r{\A(0x)?[0-9a-fA-F]{8}\Z}, %r{\A(0x)?[0-9a-fA-F]{16}\Z}, %r{\A(0x)?[0-9a-fA-F]{40}\Z})
36 id = if value.start_with?('0x')
37 value.partition('0x').last.upcase
46 desc 'The content of, or string representing, a GPG key.'
50 desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://'
51 newvalues(%r{\Ahttps?://}, %r{\Aftp://}, %r{\A/\w+})
55 if self[:source] && Pathname.new(self[:source]).absolute?
61 desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
62 defaultto :'keyserver.ubuntu.com'
64 newvalues(%r{\A((hkp|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$})
68 desc 'Additional options to pass to apt-key\'s --keyserver-options.'
71 newproperty(:fingerprint) do
73 The 40-digit hexadecimal fingerprint of the specified GPG key.
75 This property is read-only.
81 The 16-digit hexadecimal id of the specified GPG key.
83 This property is read-only.
87 newproperty(:short) do
89 The 8-digit hexadecimal id of the specified GPG key.
91 This property is read-only.
95 newproperty(:expired) do
97 Indicates if the key has expired.
99 This property is read-only.
103 newproperty(:expiry) do
105 The date the key will expire, or nil if it has no expiry date.
107 This property is read-only.
111 newproperty(:size) do
113 The key size, usually a multiple of 1024.
115 This property is read-only.
119 newproperty(:type) do
121 The key type, one of: rsa, dsa, ecc, ecdsa
123 This property is read-only.
127 newproperty(:created) do
129 Date the key was created.
131 This property is read-only.