3684f88372
Move apt-get update exec to a seperate class to minimize the number of apt-get updates invoked by configuration changes. * remove apt_update exec resource in apt class. * remove apt-get-${name} in defines. * apt::source notify Exec['apt update']. * Remove dependency to Exec['apt_update']. * fix rspec-puppet tests. Conflicts: manifests/source.pp
64 lines
1.6 KiB
Puppet
64 lines
1.6 KiB
Puppet
# source.pp
|
|
# add an apt source
|
|
|
|
define apt::source(
|
|
$ensure = present,
|
|
$location = '',
|
|
$release = $lsbdistcodename,
|
|
$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
|
|
include apt::update
|
|
|
|
$sources_list_d = $apt::params::sources_list_d
|
|
$provider = $apt::params::provider
|
|
|
|
if $release == undef {
|
|
fail('lsbdistcodename fact not available: release parameter required')
|
|
}
|
|
|
|
file { "${name}.list":
|
|
ensure => $ensure,
|
|
path => "${sources_list_d}/${name}.list",
|
|
owner => root,
|
|
group => root,
|
|
mode => '0644',
|
|
content => template("${module_name}/source.list.erb"),
|
|
notify => Exec['apt update'],
|
|
}
|
|
|
|
if ($pin != false) and ($ensure == 'present') {
|
|
apt::pin { $release:
|
|
priority => $pin,
|
|
before => File["${name}.list"]
|
|
}
|
|
}
|
|
|
|
if ($required_packages != false) and ($ensure == 'present') {
|
|
exec { "Required packages: '${required_packages}' for ${name}":
|
|
command => "${provider} -y install ${required_packages}",
|
|
subscribe => File["${name}.list"],
|
|
refreshonly => true,
|
|
}
|
|
}
|
|
|
|
# We do not want to remove keys when the source is absent.
|
|
if ($key != false) 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"],
|
|
}
|
|
}
|
|
}
|