module-puppetlabs-apt/manifests/source.pp

63 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2010-04-27 22:38:28 +02:00
# source.pp
# add an apt source
define apt::source(
2014-06-10 08:42:06 +02:00
$comment = $name,
$ensure = present,
$location = '',
$release = $::lsbdistcodename,
$repos = 'main',
$include_src = false,
$include_deb = true,
$key = undef,
$key_server = 'keyserver.ubuntu.com',
$key_content = undef,
$key_source = undef,
$pin = false,
$architecture = undef,
$trusted_source = false,
2010-04-27 22:38:28 +02:00
) {
validate_string($architecture, $comment, $location, $release, $repos, $key_server)
validate_bool($trusted_source, $include_src, $include_deb)
if ! $release {
fail('lsbdistcodename fact not available: release parameter required')
}
apt::setting { $name:
ensure => $ensure,
setting_type => 'list',
content => template('apt/_header.erb', 'apt/source.list.erb'),
notify => Exec['apt_update'],
}
if ($pin != false) {
# Get the host portion out of the url so we can pin to origin
$url_split = split($location, '/')
$host = $url_split[2]
apt::pin { $name:
ensure => $ensure,
priority => $pin,
before => Apt::Setting[$name],
origin => $host,
}
}
# We do not want to remove keys when the source is absent.
if $key and ($ensure == 'present') {
apt::key { "Add key: ${key} from Apt::Source ${title}":
ensure => present,
key => $key,
key_server => $key_server,
key_content => $key_content,
key_source => $key_source,
before => Apt::Setting[$name],
}
}
# Need anchor to provide containment for dependencies.
anchor { "apt::source::${name}":
require => Class['apt::update'],
}
2010-04-27 22:38:28 +02:00
}