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 = '',
|
2012-07-03 23:49:01 +02:00
|
|
|
$release = 'UNDEF',
|
2012-05-21 23:17:37 +02:00
|
|
|
$repos = 'main',
|
|
|
|
$include_src = true,
|
2014-07-18 10:51:32 +02:00
|
|
|
$include_deb = true,
|
2011-05-30 19:24:06 +02:00
|
|
|
$required_packages = false,
|
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,
|
|
|
|
$architecture = undef
|
2010-04-27 22:38:28 +02:00
|
|
|
) {
|
|
|
|
|
2011-05-30 19:18:13 +02:00
|
|
|
include apt::params
|
2012-05-04 22:35:13 +02:00
|
|
|
include apt::update
|
2010-04-27 22:38:28 +02:00
|
|
|
|
2012-04-11 23:54:13 +02:00
|
|
|
$sources_list_d = $apt::params::sources_list_d
|
|
|
|
$provider = $apt::params::provider
|
|
|
|
|
2012-07-03 23:49:01 +02:00
|
|
|
if $release == 'UNDEF' {
|
|
|
|
if $::lsbdistcodename == undef {
|
|
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
|
|
|
} else {
|
|
|
|
$release_real = $::lsbdistcodename
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$release_real = $release
|
2012-02-24 23:03:51 +01:00
|
|
|
}
|
|
|
|
|
2011-05-30 19:24:06 +02:00
|
|
|
file { "${name}.list":
|
2012-05-04 01:59:13 +02:00
|
|
|
ensure => $ensure,
|
2012-04-12 02:49:30 +02:00
|
|
|
path => "${sources_list_d}/${name}.list",
|
2012-03-21 14:20:13 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
|
|
|
content => template("${module_name}/source.list.erb"),
|
2012-05-04 00:44:17 +02:00
|
|
|
notify => Exec['apt_update'],
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
|
|
|
|
2012-05-21 23:19:18 +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,
|
2012-05-21 23:19:18 +02:00
|
|
|
before => File["${name}.list"],
|
|
|
|
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
|
|
|
if ($required_packages != false) and ($ensure == 'present') {
|
2012-02-24 06:01:20 +01:00
|
|
|
exec { "Required packages: '${required_packages}' for ${name}":
|
2012-04-11 23:54:13 +02:00
|
|
|
command => "${provider} -y install ${required_packages}",
|
2012-06-07 23:53:41 +02:00
|
|
|
logoutput => 'on_failure',
|
2011-05-30 19:24:06 +02:00
|
|
|
refreshonly => true,
|
2013-11-14 11:02:18 +01:00
|
|
|
tries => 3,
|
|
|
|
try_sleep => 1,
|
2012-06-07 23:53:41 +02:00
|
|
|
subscribe => File["${name}.list"],
|
2013-06-03 11:57:58 +02:00
|
|
|
before => Exec['apt_update'],
|
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,
|
|
|
|
before => File["${name}.list"],
|
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
|
|
|
}
|