8cdaf855a1
Adding this defined type allows puppet to add keys to the apt keystore without needing to add a corresponding source; it also adds the "key_source" parameter for wget'ing keys from arbitrary URLs, and allows for keys to be explicity removed. apt::key allows a key to be ensured present multiple times to account for apt::source resources that all reference the same key. However, this means that it is possible for a given key to be defined multiple times with differing source parameters. e.g. apt::key { "Add key: 4BD6EC30 from Apt::Source bunny": key => "4BD6EC30", key_server => "pgp.mit.edu", } apt::key { "Add key: 4BD6EC30 from Apt::Source rabbit": key => "4BD6EC30", key_server => "keyserver.ubuntu.com", } The defined type will accept both definitions and will create multiple exec resources. This was deemed preferable to the alternative (creating only one exec resource) in that one broken definition won't hose an entire catalog. If one definition fails to install the key because of a bad "key_server", the next apt::key that uses the key will get it done.
57 lines
1.3 KiB
Puppet
57 lines
1.3 KiB
Puppet
# source.pp
|
|
# add an apt source
|
|
|
|
define apt::source(
|
|
$location = '',
|
|
$release = 'karmic',
|
|
$repos = 'main',
|
|
$include_src = true,
|
|
$required_packages = false,
|
|
$key = false,
|
|
$key_server = 'keyserver.ubuntu.com',
|
|
$key_content = false,
|
|
$key_source = false,
|
|
$pin = false
|
|
) {
|
|
|
|
include apt::params
|
|
|
|
file { "${name}.list":
|
|
path => "${apt::params::root}/sources.list.d/${name}.list",
|
|
ensure => file,
|
|
owner => root,
|
|
group => root,
|
|
mode => 644,
|
|
content => template("apt/source.list.erb"),
|
|
|
|
}
|
|
|
|
if $pin != false {
|
|
apt::pin { "${release}": priority => "${pin}" } -> File["${name}.list"]
|
|
}
|
|
|
|
exec { "${name} apt update":
|
|
command => "${apt::params::provider} update",
|
|
subscribe => File["${name}.list"],
|
|
refreshonly => true,
|
|
}
|
|
|
|
if $required_packages != false {
|
|
exec { "Required packages: '${required_packages}' for ${name}":
|
|
command => "${apt::params::provider} -y install ${required_packages}",
|
|
subscribe => File["${name}.list"],
|
|
refreshonly => true,
|
|
}
|
|
}
|
|
|
|
if $key != false {
|
|
apt::key { "Add key: ${key} from Apt::Source ${title}":
|
|
key => $key,
|
|
ensure => present,
|
|
key_server => $key_server,
|
|
key_content => $key_content,
|
|
key_source => $key_source,
|
|
before => File["${name}.list"],
|
|
}
|
|
}
|
|
}
|