X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fpuppet%2Ftype%2Fapt_key.rb;h=467f568af4a74ff475fb2ed77da0e2c31298dc16;hb=1a8a3cc6e41f4a886490c2e58089ada3b406576b;hp=a9273e26acd5222d5ea3e5520e93d8cec190a23b;hpb=2b536b6a200e8f4f7f7ae37ec091abd06ca4cb70;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index a9273e2..467f568 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -1,29 +1,36 @@ require 'pathname' +require 'puppet/parameter/boolean' Puppet::Type.newtype(:apt_key) do - @doc = <<-EOS - This type provides Puppet with the capabilities to manage GPG keys needed - by apt to perform package validation. Apt has it's own GPG keyring that can - be manipulated through the `apt-key` command. + @doc = <<-MANIFEST + @summary This type provides Puppet with the capabilities to manage GPG keys needed + by apt to perform package validation. Apt has it's own GPG keyring that can + be manipulated through the `apt-key` command. - apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F': - source => 'http://apt.puppetlabs.com/pubkey.gpg' - } + @example Basic usage + apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F': + source => 'http://apt.puppetlabs.com/pubkey.gpg' + } - **Autorequires**: + **Autorequires** If Puppet is given the location of a key file which looks like an absolute path this type will autorequire that file. - EOS + + @api private + MANIFEST ensurable validate do + if self[:refresh] == true && self[:ensure] == :absent + raise(_('ensure => absent and refresh => true are mutually exclusive')) + end if self[:content] && self[:source] - raise('The properties content and source are mutually exclusive.') + raise(_('The properties content and source are mutually exclusive.')) end if self[:id].length < 40 - warning('The id should be a full fingerprint (40 characters), see README.') + warning(_('The id should be a full fingerprint (40 characters), see README.')) end end @@ -61,74 +68,79 @@ Puppet::Type.newtype(:apt_key) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - newvalues(%r{\A((hkp|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$}) + newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$}) end newparam(:options) do desc 'Additional options to pass to apt-key\'s --keyserver-options.' end + newparam(:refresh, boolean: true, parent: Puppet::Parameter::Boolean) do + desc 'When true, recreate an existing expired key' + defaultto false + end + newproperty(:fingerprint) do - desc <<-EOS + desc <<-MANIFEST The 40-digit hexadecimal fingerprint of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:long) do - desc <<-EOS + desc <<-MANIFEST The 16-digit hexadecimal id of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:short) do - desc <<-EOS + desc <<-MANIFEST The 8-digit hexadecimal id of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:expired) do - desc <<-EOS + desc <<-MANIFEST Indicates if the key has expired. This property is read-only. - EOS + MANIFEST end newproperty(:expiry) do - desc <<-EOS + desc <<-MANIFEST The date the key will expire, or nil if it has no expiry date. This property is read-only. - EOS + MANIFEST end newproperty(:size) do - desc <<-EOS + desc <<-MANIFEST The key size, usually a multiple of 1024. This property is read-only. - EOS + MANIFEST end newproperty(:type) do - desc <<-EOS + desc <<-MANIFEST The key type, one of: rsa, dsa, ecc, ecdsa This property is read-only. - EOS + MANIFEST end newproperty(:created) do - desc <<-EOS + desc <<-MANIFEST Date the key was created. This property is read-only. - EOS + MANIFEST end end