X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fppa.pp;h=6b38e52d63164b8249adea6e2b5142829c54050d;hb=83e20806b2a80a1807cc7d4297d015afcb86a11c;hp=af6eebff0a4064ec35a52d178a570c4222b41609;hpb=1de4e0a2944248897ad92adbdbe88fcd46ec30fb;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/ppa.pp b/manifests/ppa.pp index af6eebf..6b38e52 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,24 +1,42 @@ # ppa.pp -define apt::ppa() { +define apt::ppa( + $release = $::lsbdistcodename +) { + include apt::params + include apt::update - Class['apt'] -> Apt::Ppa[$title] + $sources_list_d = $apt::params::sources_list_d - Exec { - unless => $name? { - /ppa:(.*)/ => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*ppa.*$1.*$'", - default => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*${title}.*$'", - } + if ! $release { + fail('lsbdistcodename fact not available: release parameter required') } - exec { "apt-update-${name}": - command => "/usr/bin/aptitude update", - refreshonly => true, + $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 ! defined(Package['python-software-properties']) { + package { 'python-software-properties': } } exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", - notify => Exec["apt-update-${name}"], + creates => "${sources_list_d}/${sources_list_d_filename}", + require => [ File[$sources_list_d], + Package['python-software-properties'] ], + notify => Exec['apt_update'], + } + + file { "${sources_list_d}/${sources_list_d_filename}": + ensure => file, + require => Exec["add-apt-repository-${name}"], + } + + # Need anchor to provide containment for dependencies. + anchor { "apt::ppa::${name}": + require => Class['apt::update'], } }