Merge pull request #953 from suchpuppet/main
[puppet-modules/puppetlabs-apt.git] / manifests / source.pp
index cca03e97527ce921e93afc89db49d33c461a3580..365ba13dedc69382dc317772285638f075a6f745 100644 (file)
@@ -86,11 +86,19 @@ define apt::source(
     if ! $location {
       fail(translate('cannot create a source entry without specifying a location'))
     }
+    elsif ($::apt::proxy['https_acng']) and ($location =~ /(?i:^https:\/\/)/) {
+      $_location = regsubst($location, 'https://','http://HTTPS///')
+    }
+    else {
+      $_location = $location
+    }
     # Newer oses, do not need the package for HTTPS transport.
     $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
-    if $_release in $_transport_https_releases and $location =~ /(?i:^https:\/\/)/ {
+    if ($facts['lsbdistcodename'] in $_transport_https_releases) and $_location =~ /(?i:^https:\/\/)/ {
       ensure_packages('apt-transport-https')
     }
+  } else {
+    $_location = undef
   }
 
   $includes = merge($::apt::include_defaults, $include)
@@ -113,7 +121,7 @@ define apt::source(
     'includes'         => $includes,
     'opt_architecture' => $architecture,
     'allow_unsigned'   => $allow_unsigned,
-    'location'         => $location,
+    'location'         => $_location,
     'release'          => $_release,
     'repos'            => $repos,
   })
@@ -145,8 +153,14 @@ define apt::source(
   # We do not want to remove keys when the source is absent.
   if $key and ($ensure == 'present') {
     if $_key =~ Hash {
+      if $_key['ensure'] != undef {
+        $_ensure = $_key['ensure']
+      } else {
+        $_ensure = $ensure
+      }
+
       apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
-        ensure  => present,
+        ensure  => $_ensure,
         id      => $_key['id'],
         server  => $_key['server'],
         content => $_key['content'],