module-puppetlabs-apt/manifests/ppa.pp

64 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2010-04-27 22:38:28 +02:00
# ppa.pp
define apt::ppa(
$release = $::lsbdistcodename,
2013-09-04 23:32:42 +02:00
$options = '-y'
) {
include apt::params
include apt::update
$sources_list_d = $apt::params::sources_list_d
if ! $release {
fail('lsbdistcodename fact not available: release parameter required')
}
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
$package = $::lsbdistrelease ? {
2013-01-12 00:21:39 +01:00
/^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties',
default => 'software-properties-common',
}
2013-01-12 00:21:39 +01:00
if ! defined(Package[$package]) {
package { $package: }
}
2013-07-11 15:29:38 +02:00
if defined(Class[apt]) {
$proxy_host = $apt::proxy_host
$proxy_port = $apt::proxy_port
2013-07-11 15:29:38 +02:00
case $proxy_host {
2013-09-04 23:32:42 +02:00
false, '': {
$proxy_env = []
2013-07-11 15:29:38 +02:00
}
default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
}
} else {
$proxy_env = []
2013-07-11 15:29:38 +02:00
}
exec { "add-apt-repository-${name}":
2013-07-11 15:29:38 +02:00
environment => $proxy_env,
2013-09-04 23:32:42 +02:00
command => "/usr/bin/add-apt-repository ${options} ${name}",
unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
2013-09-04 23:32:42 +02:00
logoutput => 'on_failure',
notify => Exec['apt_update'],
require => [
2012-08-21 22:55:24 +02:00
File[$sources_list_d],
2013-09-04 23:32:42 +02:00
Package[$package],
2012-08-21 22:55:24 +02:00
],
}
file { "${sources_list_d}/${sources_list_d_filename}":
ensure => file,
2012-05-08 19:47:43 +02:00
require => Exec["add-apt-repository-${name}"],
}
# Need anchor to provide containment for dependencies.
anchor { "apt::ppa::${name}":
require => Class['apt::update'],
}
2010-04-27 22:38:28 +02:00
}