(MODULES-3307) - Auto update expired keys
[puppet-modules/puppetlabs-apt.git] / lib / puppet / type / apt_key.rb
index 10bffb46e65ae50239783558f81c404889d6ef32..5150ee8ed29f3c3d2c0f8bd5e9be37f07c02487f 100644 (file)
@@ -1,4 +1,5 @@
 require 'pathname'
+require 'puppet/parameter/boolean'
 
 Puppet::Type.newtype(:apt_key) do
   @doc = <<-MANIFEST
@@ -22,6 +23,9 @@ Puppet::Type.newtype(:apt_key) do
   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.'))
     end
@@ -71,6 +75,10 @@ Puppet::Type.newtype(:apt_key) 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'
+  end
+
   newproperty(:fingerprint) do
     desc <<-MANIFEST
       The 40-digit hexadecimal fingerprint of the specified GPG key.