Merge pull request #484 from mhaskel/merge_master_to_next
[puppet-modules/puppetlabs-apt.git] / manifests / ppa.pp
index 4181b5811d3686fa4f0f9744e2f1d289a7913023..5d4c8903d5c6d9968c64e255f63cc61466554326 100644 (file)
@@ -1,17 +1,17 @@
 # ppa.pp
 define apt::ppa(
   $ensure         = 'present',
-  $release        = $::lsbdistcodename,
   $options        = $::apt::ppa_options,
+  $release        = $::apt::xfacts['lsbdistcodename'],
   $package_name   = $::apt::ppa_package,
   $package_manage = false,
 ) {
-  if ! $release {
+  unless $release {
     fail('lsbdistcodename fact not available: release parameter required')
   }
 
-  if $::operatingsystem != 'Ubuntu' {
-    fail('apt::ppa is currently supported on Ubuntu only.')
+  if $::apt::distid != 'ubuntu' {
+    fail('apt::ppa is currently supported on Ubuntu and LinuxMint only.')
   }
 
   $filename_without_slashes = regsubst($name, '/', '-', 'G')
@@ -28,13 +28,15 @@ define apt::ppa(
       $_require = File['sources.list.d']
     }
 
-    case $::apt::proxy_host {
-      false, '', undef: {
-        $_proxy_env = []
-      }
-      default: {
-        $_proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"]
+    $_proxy = $::apt::_proxy
+    if $_proxy['host'] {
+      if $_proxy['https'] {
+        $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=https://${_proxy['host']}:${_proxy['port']}"]
+      } else {
+        $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}"]
       }
+    } else {
+      $_proxy_env = []
     }
 
     exec { "add-apt-repository-${name}":
@@ -58,9 +60,4 @@ define apt::ppa(
       notify => Exec['apt_update'],
     }
   }
-
-  # Need anchor to provide containment for dependencies.
-  anchor { "apt::ppa::${name}":
-    require => Class['apt::update'],
-  }
 }