diff -Nur apt.orig/lib/puppet/provider/apt_key/apt_key.rb apt/lib/puppet/provider/apt_key/apt_key.rb --- apt.orig/lib/puppet/provider/apt_key/apt_key.rb 2017-04-06 18:44:04.000000000 +0200 +++ apt/lib/puppet/provider/apt_key/apt_key.rb 2017-09-20 11:44:51.645966538 +0200 @@ -26,15 +26,25 @@ 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 -Nur apt.orig/manifests/init.pp apt/manifests/init.pp --- apt.orig/manifests/init.pp 2017-09-20 11:40:54.698483034 +0200 +++ apt/manifests/init.pp 2017-09-20 11:46:01.469814212 +0200 @@ -168,4 +168,19 @@ if $pins { create_resources('apt::pin', $pins) } + + # required for adding GPG keys on Debian 9 (and derivatives) + case $::operatingsystem { + 'Debian': { + if versioncmp($::operatingsystemrelease, '9.0') >= 0 { + ensure_packages(['dirmngr']) + } + } + 'Ubuntu': { + if versioncmp($::operatingsystemrelease, '17.04') >= 0 { + ensure_packages(['dirmngr']) + } + } + default: { } + } } diff -Nur apt.orig/manifests/key.pp apt/manifests/key.pp --- apt.orig/manifests/key.pp 2017-04-06 18:44:04.000000000 +0200 +++ apt/manifests/key.pp 2017-09-20 11:48:38.545471538 +0200 @@ -83,6 +83,24 @@ options => $_options, } -> anchor { "apt_key ${_id} present": } + + case $::operatingsystem { + 'Debian': { + if versioncmp($::operatingsystemrelease, '9.0') >= 0 { + Apt::Key<| title == $title |> { + require => Package['dirmngr'] + } + } + } + 'Ubuntu': { + if versioncmp($::operatingsystemrelease, '17.04') >= 0 { + Apt::Key<| title == $title |> { + require => Package['dirmngr'] + } + } + } + default: { } + } } } diff -Nur apt.orig/metadata.json apt/metadata.json --- apt.orig/metadata.json 2017-09-20 11:40:54.698483034 +0200 +++ apt/metadata.json 2017-09-20 11:50:20.257249670 +0200 @@ -17,7 +17,8 @@ "operatingsystemrelease": [ "6", "7", - "8" + "8", + "9" ] }, { @@ -26,7 +27,8 @@ "10.04", "12.04", "14.04", - "16.04" + "16.04", + "17.04" ] } ],