(#11966) Only invoke apt-get update once.
},
key_server => 'pgp.mit.edu',
pin => '200',
- notify => Exec['apt_update'],
}
}
# builddep.pp
define apt::builddep() {
+ include apt::update
Class['apt'] -> Apt::Builddep[$name]
- exec { "apt-update-${name}":
- command => '/usr/bin/apt-get update',
- refreshonly => true,
- }
-
exec { "apt-builddep-${name}":
command => "/usr/bin/apt-get -y --force-yes build-dep ${name}",
- notify => Exec["apt-update-${name}"],
+ notify => Exec['apt_update'],
}
}
) {
include apt::params
+ include apt::update
validate_bool($purge_sources_list, $purge_sources_list_d)
- $refresh_only_apt_update = $always_apt_update? {
- true => false,
- false => true,
- }
-
if ! defined(Package['python-software-properties']) {
package { 'python-software-properties': }
}
true => "# Repos managed by puppet.\n",
}
+ if $always_apt_update == true {
+ Exec <| title=='apt_update' |> {
+ refreshonly => false,
+ }
+ }
+
$root = $apt::params::root
$apt_conf_d = $apt::params::apt_conf_d
$sources_list_d = $apt::params::sources_list_d
group => root,
mode => '0644',
content => $sources_list_content,
+ notify => Exec['apt_update'],
}
file { 'sources.list.d':
group => root,
purge => $purge_sources_list_d,
recurse => $purge_sources_list_d,
- }
-
- exec { 'apt_update':
- command => "${provider} update",
- subscribe => [ File['sources.list'], File['sources.list.d'] ],
- refreshonly => $refresh_only_apt_update,
+ notify => Exec['apt_update'],
}
case $disable_keys {
path => "${apt_conf_d}/99unauth",
}
}
- undef: { } # do nothing
+ undef: { } # do nothing
default: { fail('Valid values for disable_keys are true or false') }
}
Class['apt'] -> Apt::Ppa[$title]
include apt::params
+ include apt::update
$sources_list_d = $apt::params::sources_list_d
fail('lsbdistcodename fact not available: release parameter required')
}
- exec { "apt-update-${name}":
- command => "${apt::params::provider} update",
- refreshonly => true,
- }
$filename_without_slashes = regsubst($name,'/','-','G')
$filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G')
exec { "add-apt-repository-${name}":
command => "/usr/bin/add-apt-repository ${name}",
- notify => Exec["apt-update-${name}"],
creates => "${sources_list_d}/${sources_list_d_filename}",
+ notify => Exec['apt_update'],
}
file { "${sources_list_d}/${sources_list_d_filename}":
) {
include apt::params
+ include apt::update
$sources_list_d = $apt::params::sources_list_d
$provider = $apt::params::provider
group => root,
mode => '0644',
content => template("${module_name}/source.list.erb"),
+ notify => Exec['apt_update'],
}
if ($pin != false) and ($ensure == 'present') {
}
}
- exec { "${name} apt update":
- command => "${provider} update",
- subscribe => File["${name}.list"],
- refreshonly => true,
- }
-
if ($required_packages != false) and ($ensure == 'present') {
exec { "Required packages: '${required_packages}' for ${name}":
command => "${provider} -y install ${required_packages}",
--- /dev/null
+class apt::update {
+ include apt::params
+
+ exec { 'apt_update':
+ command => "${apt::params::provider} update",
+ refreshonly => true,
+ }
+}
'owner' => "root",
'group' => "root",
'purge' => true,
- 'recurse' => true
+ 'recurse' => true,
+ 'notify' => 'Exec[apt_update]'
})
else
should create_file("sources.list.d").with({
'owner' => "root",
'group' => "root",
'purge' => false,
- 'recurse' => false
+ 'recurse' => false,
+ 'notify' => 'Exec[apt_update]'
})
end
}
it {
should contain_exec("apt_update").with({
'command' => "/usr/bin/apt-get update",
- 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
'refreshonly' => refresh_only_apt_update
})
}
'key' => '437D05B5',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
- 'notify' => 'Exec[apt_update]'
})
}
end
'key' => '55BE302B',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
- 'notify' => 'Exec[apt_update]'
})
}
end
'key' => '55BE302B',
'key_server' => 'pgp.mit.edu',
'pin' => '200',
- 'notify' => 'Exec[apt_update]'
})
}
end
describe "should succeed with a Class['apt']" do
let(:pre_condition) { 'class {"apt": } ' }
- it { should contain_exec("apt-update-#{title}").with({
+ it { should contain_exec("apt_update").with({
'command' => "/usr/bin/apt-get update",
'refreshonly' => true
})
t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
end
- it { should contain_exec("apt-update-#{t}").with(
+ it { should contain_exec("apt_update").with(
'command' => '/usr/bin/apt-get update',
'refreshonly' => true
)
it { should contain_exec("add-apt-repository-#{t}").with(
'command' => "/usr/bin/add-apt-repository #{t}",
- 'notify' => "Exec[apt-update-#{t}]",
+ 'notify' => "Exec[apt_update]",
'creates' => "/etc/apt/sources.list.d/#{filename}"
)
}
}
it {
- should contain_exec("#{title} apt update").with({
+ should contain_exec("apt_update").with({
"command" => "/usr/bin/apt-get update",
- "subscribe" => "File[#{title}.list]",
"refreshonly" => true
})
}