X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fkey.pp;h=4564c6fdf19074c456ecff2c8697bd1bd66d2ace;hb=c55a6ea90ac351e11b02bd0f9d6ae046e7b971bf;hp=dfa1daf2b61935886b79cf22b5876511807397c4;hpb=e9dadf5ed3308655d003374c4b2c2f5fe8619c27;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/key.pp b/manifests/key.pp index dfa1daf..4564c6f 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -1,27 +1,17 @@ # == Define: apt::key define apt::key ( - String $id = $title, - Enum['present', 'absent'] $ensure = present, - Optional[String] $content = undef, - Optional[String] $source = undef, - String $server = $::apt::keyserver, - Optional[String] $options = undef, - ) { - - validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) - - if $source { - validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) - } - - if $server { - validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) - } + Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title, + Enum['present', 'absent'] $ensure = present, + Optional[String] $content = undef, + Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef, + Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver, + Optional[String] $options = undef, + ) { case $ensure { present: { if defined(Anchor["apt_key ${id} absent"]){ - fail("key with id ${id} already ensured as absent") + fail(translate('key with id %{_id} already ensured as absent'),{'_id' => id}) } if !defined(Anchor["apt_key ${id} present"]) { @@ -33,12 +23,28 @@ define apt::key ( server => $server, options => $options, } -> anchor { "apt_key ${id} present": } + + case $facts['os']['name'] { + 'Debian': { + if versioncmp($facts['os']['release']['major'], '9') >= 0 { + ensure_packages(['dirmngr']) + Apt::Key<| title == $title |> + } + } + 'Ubuntu': { + if versioncmp($facts['os']['release']['full'], '17.04') >= 0 { + ensure_packages(['dirmngr']) + Apt::Key<| title == $title |> + } + } + default: { } + } } } absent: { if defined(Anchor["apt_key ${id} present"]){ - fail("key with id ${id} already ensured as present") + fail(translate('key with id %{_id} already ensured as present', {'_id' => id})) } if !defined(Anchor["apt_key ${id} absent"]){ @@ -54,7 +60,7 @@ define apt::key ( } default: { - fail "Invalid 'ensure' value '${ensure}' for apt::key" + fail translate('Invalid \'ensure\' value \'%{_ensure}\' for apt::key', {'_ensure' => ensure}) } } }