]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Add ability to specify a hash of apt::conf defines
authorGarrett Honeycutt <code@garretthoneycutt.com>
Fri, 15 Jul 2016 18:34:28 +0000 (11:34 -0700)
committerGarrett Honeycutt <code@garretthoneycutt.com>
Tue, 30 Aug 2016 14:37:32 +0000 (10:37 -0400)
README.md
manifests/init.pp
spec/classes/apt_spec.rb

index 422a862f5f5433f2727fc9f32bca2e88045b0b84..2c1d3e39af67ba1dc47ac02b19176cac20352388 100644 (file)
--- a/README.md
+++ b/README.md
@@ -260,6 +260,8 @@ Main class, includes all other classes.
 
 ##### Parameters (all optional)
 
+* `confs`: Creates new `apt::conf` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
+
 * `keys`: Creates new `apt::key` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
 
 * `ppas`: Creates new `apt::ppa` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
index 2e82502622126488f41c8f312c6fc247148c6e6c..5664edeed5220192b10bc1b0974e8ab98f557d78 100644 (file)
@@ -1,5 +1,9 @@
+# == Class: apt
 #
-class apt(
+# Manage APT (Advanced Packaging Tool)
+#
+class apt (
+  $confs    = {},
   $update   = {},
   $purge    = {},
   $proxy    = {},
@@ -63,6 +67,7 @@ class apt(
 
   $_proxy = merge($apt::proxy_defaults, $proxy)
 
+  validate_hash($confs)
   validate_hash($sources)
   validate_hash($keys)
   validate_hash($settings)
@@ -139,6 +144,9 @@ class apt(
     notify  => Class['apt::update'],
   }
 
+  if $confs {
+    create_resources('apt::conf', $confs)
+  }
   # manage sources if present
   if $sources {
     create_resources('apt::source', $sources)
index cc2264bc7a98ef7456e44513036998fa44ba6093..bf539bb35aea55312a0713db7f609e18740c5947 100644 (file)
@@ -177,6 +177,32 @@ describe 'apt' do
     it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
   end
 
+  context 'with confs defined on valid osfamily' do
+    let :facts do
+      { :osfamily        => 'Debian',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'Debian',
+        :puppetversion   => Puppet.version,
+      }
+    end
+    let(:params) { { :confs => {
+      'foo' => {
+        'content' => 'foo',
+      },
+      'bar' => {
+        'content' => 'bar',
+      }
+    } } }
+
+    it { is_expected.to contain_apt__conf('foo').with({
+        :content => 'foo',
+    })}
+
+    it { is_expected.to contain_apt__conf('bar').with({
+        :content => 'bar',
+    })}
+  end
+
   context 'with keys defined on valid osfamily' do
     let :facts do
       { :osfamily        => 'Debian',