2010-04-27 22:38:28 +02:00
|
|
|
# source.pp
|
|
|
|
# add an apt source
|
|
|
|
define apt::source(
|
2015-03-05 20:35:02 +01:00
|
|
|
$location = undef,
|
2015-03-02 22:40:06 +01:00
|
|
|
$comment = $name,
|
|
|
|
$ensure = present,
|
|
|
|
$release = $::apt::xfacts['lsbdistcodename'],
|
|
|
|
$repos = 'main',
|
2015-03-05 17:37:51 +01:00
|
|
|
$include = {},
|
2015-03-02 22:40:06 +01:00
|
|
|
$key = undef,
|
|
|
|
$pin = false,
|
|
|
|
$architecture = undef,
|
2015-03-05 20:23:38 +01:00
|
|
|
$allow_unsigned = false,
|
2010-04-27 22:38:28 +02:00
|
|
|
) {
|
2015-03-02 22:40:06 +01:00
|
|
|
validate_string($architecture, $comment, $location, $repos)
|
2015-03-05 20:23:38 +01:00
|
|
|
validate_bool($allow_unsigned)
|
2015-03-05 17:37:51 +01:00
|
|
|
validate_hash($include)
|
2015-01-13 16:27:03 +01:00
|
|
|
|
2015-03-02 22:40:06 +01:00
|
|
|
unless $release {
|
2015-02-20 00:35:47 +01:00
|
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
|
|
|
|
2015-03-05 20:35:02 +01:00
|
|
|
if $ensure == 'present' and ! $location {
|
|
|
|
fail('cannot create a source entry without specifying a location')
|
|
|
|
}
|
|
|
|
|
2015-02-28 18:02:23 +01:00
|
|
|
$_before = Apt::Setting["list-${title}"]
|
2015-03-05 17:37:51 +01:00
|
|
|
$_include = merge($::apt::include_defaults, $include)
|
2015-02-28 18:02:23 +01:00
|
|
|
|
|
|
|
if $key {
|
|
|
|
if is_hash($key) {
|
|
|
|
unless $key['id'] {
|
|
|
|
fail('key hash must contain at least an id entry')
|
|
|
|
}
|
|
|
|
$_key = merge($::apt::source_key_defaults, $key)
|
|
|
|
} else {
|
|
|
|
validate_string($key)
|
2015-03-02 22:40:06 +01:00
|
|
|
$_key = $key
|
2015-02-28 18:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 23:57:31 +01:00
|
|
|
apt::setting { "list-${name}":
|
2015-02-26 19:12:53 +01:00
|
|
|
ensure => $ensure,
|
|
|
|
content => template('apt/_header.erb', 'apt/source.list.erb'),
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
|
|
|
|
2012-05-21 23:52:36 +02:00
|
|
|
if ($pin != false) {
|
2012-05-21 23:19:18 +02:00
|
|
|
# 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:
|
2012-05-21 23:52:36 +02:00
|
|
|
ensure => $ensure,
|
2012-05-03 01:00:27 +02:00
|
|
|
priority => $pin,
|
2015-02-28 18:02:23 +01:00
|
|
|
before => $_before,
|
2012-05-21 23:19:18 +02:00
|
|
|
origin => $host,
|
2012-05-03 01:00:27 +02:00
|
|
|
}
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 01:59:13 +02:00
|
|
|
# We do not want to remove keys when the source is absent.
|
2014-02-20 16:18:37 +01:00
|
|
|
if $key and ($ensure == 'present') {
|
2015-02-28 18:02:23 +01:00
|
|
|
if is_hash($_key) {
|
|
|
|
apt::key { "Add key: ${_key['id']} from Apt::Source ${title}":
|
|
|
|
ensure => present,
|
|
|
|
id => $_key['id'],
|
|
|
|
server => $_key['server'],
|
|
|
|
content => $_key['content'],
|
|
|
|
source => $_key['source'],
|
|
|
|
options => $_key['options'],
|
|
|
|
before => $_before,
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-02 22:40:06 +01:00
|
|
|
apt::key { "Add key: ${_key} from Apt::Source ${title}":
|
2015-02-28 18:02:23 +01:00
|
|
|
ensure => present,
|
2015-03-02 22:40:06 +01:00
|
|
|
id => $_key,
|
2015-02-28 18:02:23 +01:00
|
|
|
before => $_before,
|
|
|
|
}
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|