X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fppa.pp;h=6b38e52d63164b8249adea6e2b5142829c54050d;hb=5f1cf4a24593b01a04c8886802553c1be2ec48ed;hp=a41c814f296e4a4f4c8f4462208ec3242e345a69;hpb=ee5d762351564203dec6637fb7e1547771eb03f4;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/ppa.pp b/manifests/ppa.pp index a41c814..6b38e52 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,21 +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 { "apt-update-${name}": - command => "/usr/bin/aptitude update", - refreshonly => true, + if ! $release { + fail('lsbdistcodename fact not available: release parameter required') + } + + $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}"], - 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}.*$'", - } + 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'], } }