+ # This is the location of our main exec script.
+ $cache_path = $facts['puppet_vardir']
+ $script_path = "${cache_path}/add-apt-repository-${dash_filename_no_specialchars}-${release}.sh"
+
+ if $ensure == 'present' {
+ if $package_manage {
+ ensure_packages($package_name)
+ $_require = [File['sources.list.d'], Package[$package_name]]
+ } else {
+ $_require = File['sources.list.d']
+ }
+
+ $_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 = []
+ }
+
+ unless $sources_list_d_filename in $facts['apt_sources'] {
+ $script_content = epp('apt/add-apt-repository.sh.epp', {
+ command => ['/usr/bin/add-apt-repository', shell_join($options), $name],
+ sources_list_d_path => $apt::sources_list_d,
+ sources_list_d_filename => $sources_list_d_filename,
+ }
+ )
+
+ file { "add-apt-repository-script-${name}":
+ ensure => 'file',
+ path => $script_path,
+ content => $script_content,
+ mode => '0755',
+ }
+
+ exec { "add-apt-repository-${name}":
+ environment => $_proxy_env,
+ command => $script_path,
+ logoutput => 'on_failure',
+ notify => Class['apt::update'],
+ require => $_require,
+ before => File["${apt::sources_list_d}/${sources_list_d_filename}"],
+ }
+ }
+
+ file { "${apt::sources_list_d}/${sources_list_d_filename}": }