Implement fancy progress bars configuration.
authorOliver Chick <oc243@cam.ac.uk>
Thu, 24 Apr 2014 07:52:12 +0000 (08:52 +0100)
committerOliver Chick <oliver.chick--dtg-git@cl.cam.ac.uk>
Wed, 14 May 2014 11:02:37 +0000 (12:02 +0100)
Ubuntu 14.04 ships with apt 0.9.15, has a ``fancy progress bar'', which
is a green bar that shows at the bottom of the terminal showing progress
throughout install.

This patch enables the progress bar, which is usually done by running
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar

README.md
manifests/init.pp
spec/acceptance/apt_spec.rb

index 8230f1437db24c9b07c27f702e437ff3efcf0854..ee353854c6d37e539aaa86d470da6c0ea9cd8cb7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -53,7 +53,8 @@ The parameters for `apt` are not required in general and are predominantly for d
       purge_sources_list   => false,
       purge_sources_list_d => false,
       purge_preferences_d  => false,
-      update_timeout       => undef
+      update_timeout       => undef,
+      fancy_progress       => undef
     }
 
 Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.
index 1c3f902ada5c9f9c953e908581c31a5483113959..03856a273bf00832ace479fe13d7704629862206 100644 (file)
@@ -36,7 +36,8 @@ class apt(
   $purge_preferences_d  = false,
   $update_timeout       = undef,
   $update_tries         = undef,
-  $sources              = undef
+  $sources              = undef,
+  $fancy_progress       = undef
 ) {
 
   if $::osfamily != 'Debian' {
@@ -111,6 +112,24 @@ Package: bogus-package\n",
     recurse => $purge_preferences_d,
   }
 
+  case $fancy_progress {
+    true: {
+      file { '99progressbar':
+        ensure  => present,
+        content => 'Dpkg::Progress-Fancy "1";',
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    false: {
+      file { '99progressbar':
+        ensure  => absent,
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    undef: {} # do nothing
+    default: { fail('Valid values for fancy_progress are true or false') }
+  }
+
   case $disable_keys {
     true: {
       file { '99unauth':
index f89976e4000cbbf53dda2340c5159695b52c7dc0..4daab09b7bd3852bd759458de6268fcf4ed87eb2 100644 (file)
@@ -274,6 +274,34 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
     end
   end
 
+  context 'fancy_progress => true' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => true }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should be_file }
+      it { should contain 'Dpkg::Progress-Fancy "1";' }
+    end
+  end
+  context 'fancy_progress => false' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => false }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should_not be_file }
+    end
+  end
+
   context 'reset' do
     it 'fixes the sources.list' do
       shell('cp /tmp/sources.list /etc/apt')