3 Puppet::Type.newtype(:apt_key) do
6 This type provides Puppet with the capabilities to manage GPG keys needed
7 by apt to perform package validation. Apt has it's own GPG keyring that can
8 be manipulated through the `apt-key` command.
11 source => 'http://apt.puppetlabs.com/pubkey.gpg'
16 If Puppet is given the location of a key file which looks like an absolute
17 path this type will autorequire that file.
23 if self[:content] and self[:source]
24 fail('The properties content and source are mutually exclusive.')
26 if self[:id].length < 40
27 warning('The id should be a full fingerprint (40 characters), see README.')
31 newparam(:id, :namevar => true) do
32 desc 'The ID of the key you want to manage.'
33 # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's
34 # and may start with the optional 0x, or they can be 40-digit key fingerprints
35 newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/)
37 if value.start_with?('0x')
38 id = value.partition('0x').last.upcase
47 desc 'The content of, or string representing, a GPG key.'
51 desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://'
52 newvalues(/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/)
56 if self[:source] and Pathname.new(self[:source]).absolute?
62 desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
63 defaultto :'keyserver.ubuntu.com'
65 newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/)
68 newparam(:keyserver_options) do
69 desc 'Additional options to pass to apt-key\'s --keyserver-options.'
72 newproperty(:fingerprint) do
74 The 40-digit hexadecimal fingerprint of the specified GPG key.
76 This property is read-only.
82 The 16-digit hexadecimal id of the specified GPG key.
84 This property is read-only.
88 newproperty(:short) do
90 The 8-digit hexadecimal id of the specified GPG key.
92 This property is read-only.
96 newproperty(:expired) do
98 Indicates if the key has expired.
100 This property is read-only.
104 newproperty(:expiry) do
106 The date the key will expire, or nil if it has no expiry date.
108 This property is read-only.
112 newproperty(:size) do
114 The key size, usually a multiple of 1024.
116 This property is read-only.
120 newproperty(:type) do
122 The key type, one of: rsa, dsa, ecc, ecdsa
124 This property is read-only.
128 newproperty(:created) do
130 Date the key was created.
132 This property is read-only.