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',
|
|
|
|
$release = $::lsbdistcodename,
|
|
|
|
$options = $::apt::params::ppa_options,
|
|
|
|
$package_name = $::apt::params::ppa_package,
|
|
|
|
$package_manage = true,
|
2012-02-24 23:03:51 +01:00
|
|
|
) {
|
|
|
|
include apt::params
|
2012-05-03 19:22:49 +02:00
|
|
|
include apt::update
|
2012-02-24 23:03:51 +01:00
|
|
|
|
2012-04-11 23:54:13 +02:00
|
|
|
$sources_list_d = $apt::params::sources_list_d
|
|
|
|
|
2012-02-24 23:03:51 +01:00
|
|
|
if ! $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
|
|
|
}
|
|
|
|
|
2014-01-09 20:35:17 +01:00
|
|
|
if $::operatingsystem != 'Ubuntu' {
|
2014-05-20 22:24:28 +02:00
|
|
|
fail('apt::ppa is currently supported on Ubuntu only.')
|
2014-01-09 20:35:17 +01:00
|
|
|
}
|
|
|
|
|
2013-07-22 14:48:32 +02:00
|
|
|
$filename_without_slashes = regsubst($name, '/', '-', 'G')
|
|
|
|
$filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G')
|
|
|
|
$filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G')
|
2012-05-08 19:47:43 +02:00
|
|
|
$sources_list_d_filename = "${filename_without_ppa}-${release}.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 {
|
|
|
|
if ! defined(Package[$package_name]) {
|
|
|
|
package { $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-20 23:25:53 +01:00
|
|
|
if defined(Class['apt']) {
|
|
|
|
case $::apt::proxy_host {
|
|
|
|
false, '', undef: {
|
|
|
|
$proxy_env = []
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
$proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"]
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
2015-02-20 23:25:53 +01:00
|
|
|
}
|
2013-11-09 01:50:21 +01:00
|
|
|
} else {
|
2015-02-20 23:25:53 +01:00
|
|
|
$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}",
|
|
|
|
unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
|
|
|
|
user => 'root',
|
|
|
|
logoutput => 'on_failure',
|
|
|
|
notify => Exec['apt_update'],
|
|
|
|
require => $_require,
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
file { "${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 {
|
|
|
|
file { "${sources_list_d}/${sources_list_d_filename}":
|
2015-02-20 23:25:53 +01:00
|
|
|
ensure => 'absent',
|
|
|
|
notify => Exec['apt_update'],
|
2013-11-09 01:50:21 +01:00
|
|
|
}
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
2012-05-08 00:27:53 +02:00
|
|
|
|
|
|
|
# Need anchor to provide containment for dependencies.
|
|
|
|
anchor { "apt::ppa::${name}":
|
|
|
|
require => Class['apt::update'],
|
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|