X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fppa.pp;h=99af21937529d983cfa4e590ef8e48c7bd3285a9;hb=6574d464c06b0f21f7ab3cf4a5b4151e1ad705f5;hp=1dc8e26fce80519d67c00c21cb16c894f00b029b;hpb=e588ab622b042855b214c2e25bc6fe4a2b4fb650;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 1dc8e26..99af219 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,52 +1,67 @@ # ppa.pp define apt::ppa( - $ensure = 'present', - $release = $::lsbdistcodename, - $options = $::apt::ppa_options, - $package_name = $::apt::ppa_package, - $package_manage = false, - $proxy = {}, + String $ensure = 'present', + Optional[String] $options = $::apt::ppa_options, + Optional[String] $release = $facts['lsbdistcodename'], + Optional[String] $package_name = $::apt::ppa_package, + Boolean $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 $facts['lsbdistid'] == 'Debian' { + fail('apt::ppa is not currently supported on Debian.') } - $filename_without_slashes = regsubst($name, '/', '-', 'G') - $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') - $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') - $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 { + $distid = downcase($facts['lsbdistid']) + $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2") + $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_${distid}_\\2") + } else { + $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2") + $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_\\2") + } + + $dash_filename_no_slashes = regsubst($dash_filename, '/', '-', 'G') + $dash_filename_no_specialchars = regsubst($dash_filename_no_slashes, '[\.\+]', '_', 'G') + $underscore_filename_no_slashes = regsubst($underscore_filename, '/', '-', 'G') + $underscore_filename_no_specialchars = regsubst($underscore_filename_no_slashes, '[\.\+]', '_', 'G') - $_proxy = merge($apt::proxy, $proxy) + $sources_list_d_filename = "${dash_filename_no_specialchars}-${release}.list" + + if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 { + $trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg" + } else { + $trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg" + } if $ensure == 'present' { if $package_manage { - package { $package_name: } - + ensure_packages($package_name) $_require = [File['sources.list.d'], Package[$package_name]] } else { $_require = File['sources.list.d'] } - case $_proxy['host'] { - false, '', undef: { - $_proxy_env = [] - } - default: { - $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_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}": environment => $_proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", + command => "/usr/bin/add-apt-repository ${options} ${name} || (rm ${::apt::sources_list_d}/${sources_list_d_filename} && false)", + unless => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename} && /usr/bin/test -f ${::apt::trusted_gpg_d}/${trusted_gpg_d_filename}", user => 'root', logoutput => 'on_failure', - notify => Exec['apt_update'], + notify => Class['apt::update'], require => $_require, } @@ -58,12 +73,7 @@ define apt::ppa( else { file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => 'absent', - notify => Exec['apt_update'], + notify => Class['apt::update'], } } - - # Need anchor to provide containment for dependencies. - anchor { "apt::ppa::${name}": - require => Class['apt::update'], - } }