From: Hunter Haugen Date: Fri, 15 Sep 2017 18:47:42 +0000 (-0700) Subject: Merge pull request #698 from deric/MODULES-4686-fix X-Git-Tag: 4.2.0~10 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c9800015fa342b9ceb7ef1a0eae27e9c481dcde8;hp=a541b4ee32ea39f3eb23d4ffa3311daba61d1118;p=puppet-modules%2Fpuppetlabs-apt.git Merge pull request #698 from deric/MODULES-4686-fix MODULES-4686: gpg keyserver import fails in Debian 9 (Stretch) --- diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 631efde..3f95c3c 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -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) diff --git a/manifests/init.pp b/manifests/init.pp index c89c223..44e66ce 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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: { } + } } diff --git a/manifests/key.pp b/manifests/key.pp index dfa1daf..8f9d66b 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -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: { } + } } } diff --git a/metadata.json b/metadata.json index a307e5d..4e65705 100644 --- a/metadata.json +++ b/metadata.json @@ -16,7 +16,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, {