2010-04-27 22:38:28 +02:00
|
|
|
# ppa.pp
|
2012-02-24 23:03:51 +01:00
|
|
|
define apt::ppa(
|
2015-02-20 23:25:53 +01:00
|
|
|
$ensure = 'present',
|
|
|
|
$options = $::apt::ppa_options,
|
2015-06-22 18:30:15 +02:00
|
|
|
$release = $::apt::xfacts['lsbdistcodename'],
|
2015-02-20 23:25:53 +01:00
|
|
|
$package_name = $::apt::ppa_package,
|
|
|
|
$package_manage = false,
|
2012-02-24 23:03:51 +01:00
|
|
|
) {
|
2015-03-02 22:40:06 +01:00
|
|
|
unless $release {
|
2012-03-21 14:20:13 +01:00
|
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
|
|
|
|
2015-06-22 18:30:15 +02:00
|
|
|
if $::apt::xfacts['lsbdistid'] == 'Debian' {
|
2015-04-08 00:45:20 +02:00
|
|
|
fail('apt::ppa is not currently supported on Debian.')
|
2014-01-09 20:35:17 +01:00
|
|
|
}
|
|
|
|
|
2016-04-27 17:26:25 +02:00
|
|
|
if versioncmp($::apt::xfacts['lsbdistrelease'], '15.10') >= 0 {
|
2016-02-03 17:13:46 +01:00
|
|
|
$distid = downcase($::apt::xfacts['lsbdistid'])
|
|
|
|
$filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2-${release}")
|
|
|
|
} else {
|
|
|
|
$filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2-${release}")
|
|
|
|
}
|
|
|
|
|
|
|
|
$filename_no_slashes = regsubst($filename, '/', '-', 'G')
|
|
|
|
$filename_no_specialchars = regsubst($filename_no_slashes, '[\.\+]', '_', 'G')
|
|
|
|
$sources_list_d_filename = "${filename_no_specialchars}.list"
|
2013-01-12 00:21:39 +01:00
|
|
|
|
2013-11-09 01:50:21 +01:00
|
|
|
if $ensure == 'present' {
|
2015-02-20 23:25:53 +01:00
|
|
|
if $package_manage {
|
2016-02-02 16:54:43 +01:00
|
|
|
ensure_packages($package_name)
|
2013-01-12 00:21:39 +01:00
|
|
|
|
2015-02-20 23:25:53 +01:00
|
|
|
$_require = [File['sources.list.d'], Package[$package_name]]
|
|
|
|
} else {
|
|
|
|
$_require = File['sources.list.d']
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
2012-04-02 09:00:59 +02:00
|
|
|
|
2015-02-27 12:34:05 +01:00
|
|
|
$_proxy = $::apt::_proxy
|
|
|
|
if $_proxy['host'] {
|
|
|
|
if $_proxy['https'] {
|
2015-04-24 00:12:30 +02:00
|
|
|
$_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"]
|
2015-02-27 12:34:05 +01:00
|
|
|
} else {
|
2015-04-24 00:12:30 +02:00
|
|
|
$_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"]
|
2015-02-20 23:25:53 +01:00
|
|
|
}
|
2015-02-27 12:34:05 +01:00
|
|
|
} else {
|
|
|
|
$_proxy_env = []
|
2013-07-11 15:29:38 +02:00
|
|
|
}
|
2015-02-20 23:25:53 +01:00
|
|
|
|
2013-11-09 01:50:21 +01:00
|
|
|
exec { "add-apt-repository-${name}":
|
2015-02-20 23:25:53 +01:00
|
|
|
environment => $_proxy_env,
|
|
|
|
command => "/usr/bin/add-apt-repository ${options} ${name}",
|
2016-07-02 02:31:05 +02:00
|
|
|
unless => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename}",
|
2015-02-20 23:25:53 +01:00
|
|
|
user => 'root',
|
|
|
|
logoutput => 'on_failure',
|
2015-07-18 01:19:33 +02:00
|
|
|
notify => Class['apt::update'],
|
2015-02-20 23:25:53 +01:00
|
|
|
require => $_require,
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 20:15:23 +01:00
|
|
|
file { "${::apt::sources_list_d}/${sources_list_d_filename}":
|
2015-02-20 23:25:53 +01:00
|
|
|
ensure => file,
|
|
|
|
require => Exec["add-apt-repository-${name}"],
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
2013-11-09 01:50:21 +01:00
|
|
|
else {
|
2015-02-20 20:15:23 +01:00
|
|
|
file { "${::apt::sources_list_d}/${sources_list_d_filename}":
|
2015-02-20 23:25:53 +01:00
|
|
|
ensure => 'absent',
|
2015-07-18 01:19:33 +02:00
|
|
|
notify => Class['apt::update'],
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|