MODULES-2269: Expose notify_update setting
authorBrett Delle Grazie <brett.dellegrazie@indigoblue.co.uk>
Thu, 23 Jul 2015 16:15:53 +0000 (17:15 +0100)
committerBrett Delle Grazie <brett.dellegrazie@indigoblue.co.uk>
Sun, 16 Aug 2015 18:16:36 +0000 (19:16 +0100)
* 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

README.md
manifests/conf.pp
manifests/pin.pp
spec/defines/conf_spec.rb

index 4220775b990bea62f602b447ed5695955e4c359a..8c3819b262e9133f2929b65cb778dbf6b31fcb07 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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'.
 
+* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'.
+
 #### Define: `apt::key`
 
 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`
 
-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)
 
index c0cd55ba9e145b4b2a01437d5903ce3467851d9d..97b70a1eebfaceae39f74345c842c7f172d587e7 100644 (file)
@@ -1,7 +1,8 @@
 define apt::conf (
-  $content  = undef,
-  $ensure   = present,
-  $priority = '50',
+  $content       = undef,
+  $ensure        = present,
+  $priority      = '50',
+  $notify_update = undef,
 ) {
 
   unless $ensure == 'absent' {
@@ -11,8 +12,9 @@ define apt::conf (
   }
 
   apt::setting { "conf-${name}":
-    ensure   => $ensure,
-    priority => $priority,
-    content  => template('apt/_conf_header.erb', 'apt/conf.erb'),
+    ensure        => $ensure,
+    priority      => $priority,
+    content       => template('apt/_conf_header.erb', 'apt/conf.erb'),
+    notify_update => $notify_update,
   }
 }
index bcccf28b7c8058532e30827c172a58f0f171bc1b..cc896896d79ab672f822a4be1e8dbdcc5668f38f 100644 (file)
@@ -72,8 +72,9 @@ define apt::pin(
   $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
 
   apt::setting { "pref-${file_name}":
-    ensure   => $ensure,
-    priority => $order,
-    content  => template('apt/_header.erb', 'apt/pin.pref.erb'),
+    ensure        => $ensure,
+    priority      => $order,
+    content       => template('apt/_header.erb', 'apt/pin.pref.erb'),
+    notify_update => false,
   }
 }
index f0192d61c414b067c474450ec4c87afd61ea3f16..c74bf1aca340265897e3c1d8fcfcb24850cde4a3 100644 (file)
@@ -9,12 +9,15 @@ describe 'apt::conf', :type => :define do
   end
 
   describe "when creating an apt preference" do
-    let :params do
+    let :default_params do
       {
         :priority => '00',
         :content  => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
       }
     end
+    let :params do
+      default_params
+    end
 
     let :filename do
       "/etc/apt/apt.conf.d/00norecommends"
@@ -28,6 +31,22 @@ describe 'apt::conf', :type => :define do
           '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
 
   describe "when creating a preference without content" do