3e44b685d2
Add them to PPA since they were being used there, and add a placeholder example for setting up the proxy files.
69 lines
2 KiB
Puppet
69 lines
2 KiB
Puppet
# ppa.pp
|
|
define apt::ppa(
|
|
$ensure = 'present',
|
|
$release = $::lsbdistcodename,
|
|
$options = $::apt::ppa_options,
|
|
$package_name = $::apt::ppa_package,
|
|
$package_manage = false,
|
|
$proxy = {},
|
|
) {
|
|
if ! $release {
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
|
}
|
|
|
|
if $::operatingsystem != 'Ubuntu' {
|
|
fail('apt::ppa is currently supported on Ubuntu only.')
|
|
}
|
|
|
|
$filename_without_slashes = regsubst($name, '/', '-', 'G')
|
|
$filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G')
|
|
$filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G')
|
|
$sources_list_d_filename = "${filename_without_ppa}-${release}.list"
|
|
|
|
$_proxy = merge($apt::proxy, $proxy)
|
|
|
|
if $ensure == 'present' {
|
|
if $package_manage {
|
|
package { $package_name: }
|
|
|
|
$_require = [File['sources.list.d'], Package[$package_name]]
|
|
} else {
|
|
$_require = File['sources.list.d']
|
|
}
|
|
|
|
case $_proxy['host'] {
|
|
false, '', undef: {
|
|
$_proxy_env = []
|
|
}
|
|
default: {
|
|
$_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_proxy['port']}"]
|
|
}
|
|
}
|
|
|
|
exec { "add-apt-repository-${name}":
|
|
environment => $_proxy_env,
|
|
command => "/usr/bin/add-apt-repository ${options} ${name}",
|
|
unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}",
|
|
user => 'root',
|
|
logoutput => 'on_failure',
|
|
notify => Exec['apt_update'],
|
|
require => $_require,
|
|
}
|
|
|
|
file { "${::apt::sources_list_d}/${sources_list_d_filename}":
|
|
ensure => file,
|
|
require => Exec["add-apt-repository-${name}"],
|
|
}
|
|
}
|
|
else {
|
|
file { "${::apt::sources_list_d}/${sources_list_d_filename}":
|
|
ensure => 'absent',
|
|
notify => Exec['apt_update'],
|
|
}
|
|
}
|
|
|
|
# Need anchor to provide containment for dependencies.
|
|
anchor { "apt::ppa::${name}":
|
|
require => Class['apt::update'],
|
|
}
|
|
}
|