Merge pull request #596 from danielhoherd/master
authorTP Honey <tphoney@users.noreply.github.com>
Tue, 12 Apr 2016 09:46:39 +0000 (10:46 +0100)
committerTP Honey <tphoney@users.noreply.github.com>
Tue, 12 Apr 2016 09:46:39 +0000 (10:46 +0100)
Expose notify_update to apt::source

README.md
manifests/source.pp
spec/defines/source_spec.rb

index 30dfed24164b11a747ed2e7e4b83e0f9e63e98b4..49266cc913b3837839694b9b52de0c05b42f1c67 100644 (file)
--- a/README.md
+++ b/README.md
@@ -485,6 +485,8 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`.
 
 * `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module.
 
+* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'.
+
 #### Type: `apt_key`
 
 Manages the GPG keys that Apt uses to authenticate packages.
index 1307a3a552be523dfd02f988066eccf47ced7b2a..0bb9b3be7161bd3929e12e08bcfa7d8b7fa715da 100644 (file)
@@ -18,6 +18,7 @@ define apt::source(
   $key_content       = undef,
   $key_source        = undef,
   $trusted_source    = undef,
+  $notify_update     = undef,
 ) {
   validate_string($architecture, $comment, $location, $repos)
   validate_bool($allow_unsigned)
@@ -114,8 +115,9 @@ define apt::source(
   }
 
   apt::setting { "list-${name}":
-    ensure  => $ensure,
-    content => template('apt/_header.erb', 'apt/source.list.erb'),
+    ensure        => $ensure,
+    content       => template('apt/_header.erb', 'apt/source.list.erb'),
+    notify_update => $notify_update,
   }
 
   if $pin {
index cfae55cc8f7e2ae01989a4fd2e26dedde6687bad..4c3321af96117f0622758b45573efa360a993e71 100644 (file)
@@ -387,5 +387,58 @@ describe 'apt::source' do
       end
     end
 
+    context "with notify_update = undef (default)" do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+          :lsbdistcodename => 'wheezy',
+          :osfamily        => 'Debian',
+          :puppetversion   => Puppet.version,
+        }
+      end
+      let :params do
+        {
+          :location      => 'hello.there',
+        }
+      end
+      it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
+    end
+
+    context "with notify_update = true" do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+          :lsbdistcodename => 'wheezy',
+          :osfamily        => 'Debian',
+          :puppetversion   => Puppet.version,
+        }
+      end
+      let :params do
+        {
+          :location      => 'hello.there',
+          :notify_update => true,
+        }
+      end
+      it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
+    end
+
+    context "with notify_update = false" do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+          :lsbdistcodename => 'wheezy',
+          :osfamily        => 'Debian',
+          :puppetversion   => Puppet.version,
+        }
+      end
+      let :params do
+        {
+          :location      => 'hello.there',
+          :notify_update => false,
+        }
+      end
+      it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }
+    end
+
   end
 end