Merge pull request #698 from deric/MODULES-4686-fix
authorHunter Haugen <hunter@puppet.com>
Fri, 15 Sep 2017 18:47:42 +0000 (11:47 -0700)
committerHunter Haugen <hunter@puppet.com>
Fri, 15 Sep 2017 18:47:42 +0000 (11:47 -0700)
MODULES-4686: gpg keyserver import fails in Debian 9 (Stretch)

lib/puppet/provider/apt_key/apt_key.rb
manifests/init.pp
manifests/key.pp
metadata.json

index 631efde312103dd1dc261b0cb8dc47ffb5efb3c6..3f95c3cc96af9c68f40234d6f07a9a3072be5173 100644 (file)
@@ -26,17 +26,25 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       key_output = apt_key(cli_args)
     end
 
-    pub_line, fpr_line = nil
+    pub_line, sub_line, fpr_line = nil
 
     key_array = key_output.split("\n").collect do |line|
       if line.start_with?('pub')
           pub_line = line
           # reset fpr_line, to skip any previous subkeys which were collected
           fpr_line = nil
+          sub_line = nil
+      elsif line.start_with?('sub')
+          sub_line = line
       elsif line.start_with?('fpr')
           fpr_line = line
       end
 
+      if (sub_line and fpr_line)
+        sub_line, fpr_line = nil
+        next
+      end
+
       next unless (pub_line and fpr_line)
 
       line_hash = key_line_hash(pub_line, fpr_line)
index c89c2230cfd684c108acb924ca74868f345e8222..44e66ce51ff2dd00980603ae05423c11d092cae3 100644 (file)
@@ -178,4 +178,19 @@ class apt (
   if $pins {
     create_resources('apt::pin', $pins)
   }
+
+  # required for adding GPG keys on Debian 9 (and derivatives)
+  case $facts['os']['name'] {
+    'Debian': {
+      if versioncmp($facts['os']['release']['full'], '9.0') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    'Ubuntu': {
+      if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    default: { }
+  }
 }
index dfa1daf2b61935886b79cf22b5876511807397c4..8f9d66bcc9a1bf2b45742fec5007a9a849a98f31 100644 (file)
@@ -33,6 +33,24 @@ define apt::key (
           server  => $server,
           options => $options,
         } -> anchor { "apt_key ${id} present": }
+
+        case $facts['os']['name'] {
+          'Debian': {
+            if versioncmp($facts['os']['release']['full'], '9.0') >= 0 {
+              Apt::Key<| title == $title |> {
+                require => Package['dirmngr']
+              }
+            }
+          }
+          'Ubuntu': {
+            if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+              Apt::Key<| title == $title |> {
+                require => Package['dirmngr']
+              }
+            }
+          }
+          default: { }
+        }
       }
     }
 
index a307e5db9bbb4161c39291f52c092cbf6cf072fd..4e65705322cf6e65663e3224b75eecbc388f1052 100644 (file)
@@ -16,7 +16,8 @@
       "operatingsystem": "Debian",
       "operatingsystemrelease": [
         "7",
-        "8"
+        "8",
+        "9"
       ]
     },
     {