module-puppetlabs-apt/manifests/source.pp
Morgan Haskel 7c5a62f13e Stop redeclaring variables from params
It really seems unnecessary.
2015-02-21 12:18:15 -08:00

73 lines
1.9 KiB
Puppet

# source.pp
# add an apt source
define apt::source(
$comment = $name,
$ensure = present,
$location = '',
$release = 'UNDEF',
$repos = 'main',
$include_src = true,
$include_deb = true,
$key = undef,
$key_server = 'keyserver.ubuntu.com',
$key_content = undef,
$key_source = undef,
$pin = false,
$architecture = undef,
$trusted_source = false,
) {
validate_string($architecture)
validate_bool($trusted_source)
if $release == 'UNDEF' {
if $::lsbdistcodename == undef {
fail('lsbdistcodename fact not available: release parameter required')
} else {
$release_real = $::lsbdistcodename
}
} else {
$release_real = $release
}
file { "${name}.list":
ensure => $ensure,
path => "${::apt::sources_list_d}/${name}.list",
owner => root,
group => root,
mode => '0644',
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 => File["${name}.list"],
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 => File["${name}.list"],
}
}
# Need anchor to provide containment for dependencies.
anchor { "apt::source::${name}":
require => Class['apt::update'],
}
}