MODULES-2269: Expose notify_update setting

* Expose the underlying notify_update setting of the apt::settings resource
This is because not all configuration file changes should trigger an apt::update notification
* apt::pin also shouldn't result in an apt-update call
Adding a pin configuration should apply to the next apt-get update call it shouldn't trigger one itself.
* Added documentation
* Add tests for apt::conf notify_update
This commit is contained in:
Brett Delle Grazie 2015-07-23 17:15:53 +01:00
parent 849d000ff3
commit 9ad4fd682d
4 changed files with 35 additions and 11 deletions

View file

@ -291,6 +291,8 @@ Specifies a custom Apt configuration file.
* `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'. * `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'.
* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'.
#### Define: `apt::key` #### Define: `apt::key`
Manages the GPG keys that Apt uses to authenticate packages. Manages the GPG keys that Apt uses to authenticate packages.
@ -323,7 +325,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi
#### Define: `apt::pin` #### Define: `apt::pin`
Manages Apt pins. Manages Apt pins. Does not trigger an `apt-get update` run.
**Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences) **Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences)

View file

@ -2,6 +2,7 @@ define apt::conf (
$content = undef, $content = undef,
$ensure = present, $ensure = present,
$priority = '50', $priority = '50',
$notify_update = undef,
) { ) {
unless $ensure == 'absent' { unless $ensure == 'absent' {
@ -14,5 +15,6 @@ define apt::conf (
ensure => $ensure, ensure => $ensure,
priority => $priority, priority => $priority,
content => template('apt/_conf_header.erb', 'apt/conf.erb'), content => template('apt/_conf_header.erb', 'apt/conf.erb'),
notify_update => $notify_update,
} }
} }

View file

@ -75,5 +75,6 @@ define apt::pin(
ensure => $ensure, ensure => $ensure,
priority => $order, priority => $order,
content => template('apt/_header.erb', 'apt/pin.pref.erb'), content => template('apt/_header.erb', 'apt/pin.pref.erb'),
notify_update => false,
} }
} }

View file

@ -9,12 +9,15 @@ describe 'apt::conf', :type => :define do
end end
describe "when creating an apt preference" do describe "when creating an apt preference" do
let :params do let :default_params do
{ {
:priority => '00', :priority => '00',
:content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
} }
end end
let :params do
default_params
end
let :filename do let :filename do
"/etc/apt/apt.conf.d/00norecommends" "/etc/apt/apt.conf.d/00norecommends"
@ -28,6 +31,22 @@ describe 'apt::conf', :type => :define do
'mode' => '0644', 'mode' => '0644',
}) })
} }
context "with notify_update = true (default)" do
let :params do
default_params
end
it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) }
end
context "with notify_update = false" do
let :params do
default_params.merge({
:notify_update => false
})
end
it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) }
end
end end
describe "when creating a preference without content" do describe "when creating a preference without content" do