(ISSUE-1036) Conditional `gnupg` include added to init.pp
[puppet-modules/puppetlabs-apt.git] / manifests / init.pp
index 7e4b4c981cc97d9f8db4631af8f005c309cc93bd..704311061b6df0e7f6d649c70721554e29d84ad1 100644 (file)
@@ -143,7 +143,7 @@ class apt (
   Hash $settings                = $apt::params::settings,
   Boolean $manage_auth_conf     = $apt::params::manage_auth_conf,
   Array[Apt::Auth_conf_entry]
-    $auth_conf_entries          = $apt::params::auth_conf_entries,
+  $auth_conf_entries            = $apt::params::auth_conf_entries,
   String $auth_conf_owner       = $apt::params::auth_conf_owner,
   String $root                  = $apt::params::root,
   String $sources_list          = $apt::params::sources_list,
@@ -163,7 +163,6 @@ class apt (
   }
 
 ) inherits apt::params {
-
   if $facts['os']['family'] != 'Debian' {
     fail('This module only works on Debian or derivatives like Ubuntu')
   }
@@ -226,10 +225,10 @@ class apt (
     $_perhost = {}
   }
 
-  $_proxy = merge($apt::proxy_defaults, $proxy, { 'perhost' => $_perhost } )
+  $_proxy = merge($apt::proxy_defaults, $proxy, { 'perhost' => $_perhost })
 
   $confheadertmp = epp('apt/_conf_header.epp')
-  $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
+  $proxytmp = epp('apt/proxy.epp', { 'proxies' => $_proxy })
   $updatestamptmp = epp('apt/15update-stamp.epp')
 
   if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
@@ -249,9 +248,7 @@ class apt (
       true    => nil,
       default => undef,
     }
-  }
-  else
-    {
+  } else {
     $sources_list_ensure = $_purge['sources.list'] ? {
       true    => file,
       default => file,
@@ -361,4 +358,20 @@ class apt (
   if $pins {
     create_resources('apt::pin', $pins)
   }
+
+  case $facts['os']['name'] {
+    'Debian': {
+      if versioncmp($facts['os']['release']['major'], '9') >= 0 {
+        ensure_packages(['gnupg'])
+      }
+    }
+    'Ubuntu': {
+      if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+        ensure_packages(['gnupg'])
+      }
+    }
+    default: {
+      # Nothing in here
+    }
+  }
 }