From 1af9a13c40c33e1ab8fb56f33cb9aa5e16cead0e Mon Sep 17 00:00:00 2001 From: Robert Navarro Date: Thu, 18 Aug 2011 02:37:54 -0300 Subject: [PATCH 1/2] Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! --- manifests/ppa.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 8dcea85..1576927 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -4,6 +4,10 @@ define apt::ppa() { Class['apt'] -> Apt::Ppa[$title] + Exec { + onlyif => "/usr/bin/test ! $(/bin/ls /etc/apt/sources.list.d | /bin/grep -v $(echo \"${title}\" | /usr/bin/gawk 'match(\$0, /^ppa:(.*)\/(.*)$/, vals) {printf \"%s-%s\", vals[1], vals[2]}'))", + } + exec { "apt-update-${name}": command => "/usr/bin/aptitude update", refreshonly => true, From 1de4e0a2944248897ad92adbdbe88fcd46ec30fb Mon Sep 17 00:00:00 2001 From: Robert Navarro Date: Wed, 24 Aug 2011 22:52:42 -0400 Subject: [PATCH 2/2] Refactored as per mlitteken * https://github.com/rnavarro/puppet-apt/commit/1af9a13c40c33e1ab8fb56f33cb9aa5e16cead0e#commitcomment-539287 --- manifests/ppa.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 1576927..af6eebf 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -5,7 +5,10 @@ define apt::ppa() { Class['apt'] -> Apt::Ppa[$title] Exec { - onlyif => "/usr/bin/test ! $(/bin/ls /etc/apt/sources.list.d | /bin/grep -v $(echo \"${title}\" | /usr/bin/gawk 'match(\$0, /^ppa:(.*)\/(.*)$/, vals) {printf \"%s-%s\", vals[1], vals[2]}'))", + 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}.*$'", + } } exec { "apt-update-${name}":