Merge pull request #290 from dpnl87/wheezy-preference-fix
authorAshley Penney <ashley.penney@puppetlabs.com>
Mon, 5 May 2014 15:54:52 +0000 (11:54 -0400)
committerAshley Penney <ashley.penney@puppetlabs.com>
Mon, 5 May 2014 15:54:52 +0000 (11:54 -0400)
Do not add bogus line to apt preference file on Debian Wheezy

README.md
manifests/init.pp
spec/acceptance/apt_spec.rb
spec/acceptance/nodesets/debian-73-x64.yml [new file with mode: 0644]
spec/classes/apt_spec.rb

index 8230f1437db24c9b07c27f702e437ff3efcf0854..9443cd561d6160c94a4c57bb548cda1341ddd927 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ Setup
 **What APT affects:**
 
 * package/service/configuration files for APT
+    * NOTE: Setting the `purge_preferences` or `purge_preferences_d` parameters to 'true' will destroy any existing configuration that was not declared with puppet. The default for these parameters is 'false'.
 * your system's `sources.list` file and `sources.list.d` directory
     * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'.
 * system repositories
@@ -58,7 +59,7 @@ The parameters for `apt` are not required in general and are predominantly for d
 
 Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.
 
-If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
+If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
 
 ### apt::builddep
 
@@ -319,3 +320,4 @@ A lot of great people have contributed to this module. A somewhat current list f
 * William Van Hevelingen <blkperl@cat.pdx.edu> <wvan13@gmail.com>
 * Zach Leslie <zach@puppetlabs.com>
 * Daniele Sluijters <github@daenney.net>
+* Daniel Paulus <daniel@inuits.eu>
index 1c3f902ada5c9f9c953e908581c31a5483113959..48b62d178a30056b83d4edbde6598397bfad4497 100644 (file)
@@ -54,13 +54,6 @@ class apt(
     true  => "# Repos managed by puppet.\n",
   }
 
-  $preferences_content = $purge_preferences ? {
-    false => undef,
-    true  => "Explanation: Preferences managed by Puppet\n
-Explanation: We need a bogus package line because of Debian Bug #732746\n
-Package: bogus-package\n",
-  }
-
   if $always_apt_update == true {
     Exec <| title=='apt_update' |> {
       refreshonly => false,
@@ -93,13 +86,11 @@ Package: bogus-package\n",
     notify  => Exec['apt_update'],
   }
 
-  file { 'apt-preferences':
-    ensure  => present,
-    path    => "${root}/preferences",
-    owner   => root,
-    group   => root,
-    mode    => '0644',
-    content => $preferences_content,
+  if $purge_preferences {
+    file { 'apt-preferences':
+      ensure  => absent,
+      path    => "${root}/preferences",
+    }
   }
 
   file { 'preferences.d':
index f89976e4000cbbf53dda2340c5159695b52c7dc0..13f1d50536c036100fef5d28f75295ff16b3da28 100644 (file)
@@ -217,10 +217,7 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
       end
 
       describe file('/etc/apt/preferences') do
-        it { should be_file }
-        it 'is managed by Puppet' do
-          shell("grep 'Explanation' /etc/apt/preferences", {:acceptable_exit_codes => 0})
-        end
+        it { should_not be_file }
       end
     end
   end
diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml
new file mode 100644 (file)
index 0000000..d714345
--- /dev/null
@@ -0,0 +1,11 @@
+HOSTS:
+  debian-73-x64:
+    roles:
+      - master
+    platform: debian-7-amd64
+    box : debian-73-x64-virtualbox-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  log_level: debug
+  type: git
\ No newline at end of file
index 9f18a9126454ae1e2807117dd6d24305c2e4166a..a21e0443e2df715b221e712d9457607d26117611 100644 (file)
@@ -93,22 +93,11 @@ describe 'apt', :type => :class do
       it {
         if param_hash[:purge_preferences]
           should create_file('apt-preferences').with({
-            :ensure  => 'present',
+            :ensure  => 'absent',
             :path    => '/etc/apt/preferences',
-            :owner   => 'root',
-            :group   => 'root',
-            :mode    => '0644',
-            :content => /Explanation/,
           })
         else
-          should create_file('apt-preferences').with({
-            :ensure  => 'present',
-            :path    => '/etc/apt/preferences',
-            :owner   => 'root',
-            :group   => 'root',
-            :mode    => '0644',
-            :content => nil,
-          })
+          should_not contain_file('apt-preferences')
         end
       }