Merge pull request #1056 from puppetlabs/gh-1055-hardcoded_cache_path
authorLukas Audzevicius <97180854+LukasAud@users.noreply.github.com>
Wed, 31 Aug 2022 10:27:52 +0000 (11:27 +0100)
committerGitHub <noreply@github.com>
Wed, 31 Aug 2022 10:27:52 +0000 (11:27 +0100)
(GH-1055) Fix hardcoded cache path

1  2 
manifests/ppa.pp

diff --combined manifests/ppa.pp
index e3c53e8e6d6f5226962da2507e4ce41dc97e0ff3,f3613a0b56523fd62b86a49a557271fa8773015a..f6cba8d38abff2d597797b7ac98f9627f9d5def0
  #
  define apt::ppa (
    String $ensure                        = 'present',
 -  Optional[Array[String]] $options      = $::apt::ppa_options,
 +  Optional[Array[String]] $options      = $apt::ppa_options,
    Optional[String] $release             = fact('os.distro.codename'),
    Optional[String] $dist                = $facts['os']['name'],
 -  Optional[String] $package_name        = $::apt::ppa_package,
 +  Optional[String] $package_name        = $apt::ppa_package,
    Boolean $package_manage               = false,
  ) {
    unless $release {
    $sources_list_d_filename  = "${dash_filename_no_specialchars}-${release}.list"
  
    if versioncmp($facts['os']['release']['full'], '15.10') >= 0 and
 -    versioncmp($facts['os']['release']['full'], '21.04') < 0 {
 +  versioncmp($facts['os']['release']['full'], '21.04') < 0 {
      $trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg"
    } else {
      $trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg"
    }
  
-   # This is the location of our main exec script  
-   $script_path = "/opt/puppetlabs/puppet/cache/add-apt-repository-${dash_filename_no_specialchars}-${release}.sh"
+   # 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 {
@@@ -78,7 -79,7 +79,7 @@@
        $_require = File['sources.list.d']
      }
  
 -    $_proxy = $::apt::_proxy
 +    $_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']}"]
  
      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,
 -      })
 +          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',
      }
  
      tidy { "remove-apt-repository-${name}":
 -      path   => "${::apt::sources_list_d}/${sources_list_d_filename}",
 +      path   => "${apt::sources_list_d}/${sources_list_d_filename}",
        notify => Class['apt::update'],
      }
    }