module-puppetlabs-apt/manifests/ppa.pp
William Van Hevelingen 7c0d10b392 (#12809) $release should use $lsbdistcodename and fall back to manual input
This commit changes $release to default to Facter's $lsbdistcodename
and fall back to a Parse Error if $release is not set and $lsbdistcodename
does not exist. Previously $release was hardcoded to karmic.

This commit also modifies apt::ppa to use $release and sets the
files to be ensured so that they are not purged when purge_sources_list_d
is set to true.
2012-03-01 11:15:02 -08:00

36 lines
908 B
Puppet

# ppa.pp
define apt::ppa(
$release = $lsbdistcodename
) {
Class['apt'] -> Apt::Ppa[$title]
include apt::params
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_ppa = regsubst($filename_without_slashes, '^ppa:','','G')
$sources_list_d_filename = "${filename_without_ppa}-${release}.list"
exec { "add-apt-repository-${name}":
command => "/usr/bin/add-apt-repository ${name}",
notify => Exec["apt-update-${name}"],
creates => "${apt::params::sources_list_d}/${sources_list_d_filename}",
}
file { "${apt::params::sources_list_d}/${sources_list_d_filename}":
ensure => file,
require => Exec["add-apt-repository-${name}"];
}
}