Merge pull request #731 from willmeek/rubocopification
[puppet-modules/puppetlabs-apt.git] / manifests / init.pp
index c89c2230cfd684c108acb924ca74868f345e8222..aa61986d21fdc992b3b3cecf85c898f6ea35a7f1 100644 (file)
@@ -35,10 +35,11 @@ class apt (
     fail('This module only works on Debian or derivatives like Ubuntu')
   }
 
-  $frequency_options = ['always','daily','weekly','reluctantly']
-
   if $update['frequency'] {
-    validate_re($update['frequency'], $frequency_options)
+    assert_type(
+      Enum['always','daily','weekly','reluctantly'],
+      $update['frequency'],
+    )
   }
   if $update['timeout'] {
     assert_type(Integer, $update['timeout'])
@@ -66,7 +67,7 @@ class apt (
   $_purge = merge($::apt::purge_defaults, $purge)
 
   if $proxy['ensure'] {
-    validate_re($proxy['ensure'], ['file', 'present', 'absent'])
+    assert_type(Enum['file', 'present', 'absent'], $proxy['ensure'])
   }
   if $proxy['host'] {
     assert_type(String, $proxy['host'])
@@ -77,6 +78,9 @@ class apt (
   if $proxy['https']{
     assert_type(Boolean, $proxy['https'])
   }
+  if $proxy['direct']{
+    assert_type(Boolean, $proxy['direct'])
+  }
 
   $_proxy = merge($apt::proxy_defaults, $proxy)
 
@@ -178,4 +182,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']['major'], '9') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    'Ubuntu': {
+      if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    default: { }
+  }
 }