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,
|
2012-05-21 23:17:37 +02:00
|
|
|
$ensure = present,
|
|
|
|
$location = '',
|
2015-02-20 00:35:47 +01:00
|
|
|
$release = $::lsbdistcodename,
|
2012-05-21 23:17:37 +02:00
|
|
|
$repos = 'main',
|
2015-02-20 00:35:47 +01:00
|
|
|
$include_src = false,
|
2014-07-18 10:51:32 +02:00
|
|
|
$include_deb = true,
|
2014-02-20 16:18:37 +01:00
|
|
|
$key = undef,
|
2012-05-21 23:17:37 +02:00
|
|
|
$key_server = 'keyserver.ubuntu.com',
|
2014-02-20 16:18:37 +01:00
|
|
|
$key_content = undef,
|
|
|
|
$key_source = undef,
|
2013-05-30 00:52:32 +02:00
|
|
|
$pin = false,
|
2015-01-13 16:27:03 +01:00
|
|
|
$architecture = undef,
|
2015-01-21 19:54:37 +01:00
|
|
|
$trusted_source = false,
|
2010-04-27 22:38:28 +02:00
|
|
|
) {
|
2015-02-20 00:35:47 +01:00
|
|
|
validate_string($architecture, $comment, $location, $release, $repos, $key_server)
|
|
|
|
validate_bool($trusted_source, $include_src, $include_deb)
|
2015-01-13 16:27:03 +01:00
|
|
|
|
2015-02-20 00:35:47 +01:00
|
|
|
if ! $release {
|
|
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
|
|
|
|
2015-02-21 21:11:57 +01:00
|
|
|
apt::setting { $name:
|
|
|
|
ensure => $ensure,
|
|
|
|
setting_type => 'list',
|
|
|
|
content => template('apt/_header.erb', 'apt/source.list.erb'),
|
|
|
|
notify => Exec['apt_update'],
|
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-21 21:11:57 +01:00
|
|
|
before => Apt::Setting[$name],
|
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') {
|
2012-02-24 19:10:03 +01:00
|
|
|
apt::key { "Add key: ${key} from Apt::Source ${title}":
|
|
|
|
ensure => present,
|
2012-03-21 14:20:13 +01:00
|
|
|
key => $key,
|
2012-02-24 19:10:03 +01:00
|
|
|
key_server => $key_server,
|
|
|
|
key_content => $key_content,
|
|
|
|
key_source => $key_source,
|
2015-02-21 21:11:57 +01:00
|
|
|
before => Apt::Setting[$name],
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-08 00:27:53 +02:00
|
|
|
|
|
|
|
# Need anchor to provide containment for dependencies.
|
|
|
|
anchor { "apt::source::${name}":
|
|
|
|
require => Class['apt::update'],
|
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|