]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
introduce preferences snippet
authormh <mh@immerda.ch>
Sun, 17 Oct 2010 11:58:59 +0000 (13:58 +0200)
committermh <mh@immerda.ch>
Sun, 17 Oct 2010 11:58:59 +0000 (13:58 +0200)
Now, we have the possibility to externally add snippes, so that
we can preferences for packages that are for example only in backports
or unstable.

README
manifests/default_preferences.pp [deleted file]
manifests/init.pp
manifests/module_dir.pp [new file with mode: 0644]
manifests/preferences.pp [new file with mode: 0644]
manifests/preferences_snippet.pp [new file with mode: 0644]
manifests/unattended_upgrades.pp

diff --git a/README b/README
index e624bba6583789a7556ab020dd500ad79b689274..b52a024a2dc395e2e390362dfd0030af4e75040c 100644 (file)
--- a/README
+++ b/README
@@ -50,17 +50,6 @@ following variable before including this class will pull in the
 templates/apt/sources.list file: 
 $custom_sources_list ='template("apt/sources.list")'
                       
-$custom_preferences    
---------------------
-By default this module will use a basic apt/preferences file with
-unstable and testing pinned to very low values so that any package
-installation will not accidentally pull in packages from those suites
-unless you explicitly specify the version number. You can set this
-variable to pull in a customized apt/preferences template, for
-example, setting the following variable before including this class
-will pull in the templates/apt/preferences file: 
-$custom_preferences = 'template("apt/preferences")'
-
 $custom_key_dir
 ---------------
 If you have different apt-key files that you want to get added to your
@@ -81,6 +70,14 @@ Classes
 This module contains only the apt class, which sets up all described
 functionality.
 
+Defines
+=======
+
+apt::preferences_snippet
+------------------------
+
+A way to add pinning information to /etc/apt/preferences
+
 
 Resources
 =========
diff --git a/manifests/default_preferences.pp b/manifests/default_preferences.pp
deleted file mode 100644 (file)
index 3cdb355..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-class apt::default_preferences {
-  config_file {
-    # this just pins unstable and testing to very low values
-    "/etc/apt/preferences":
-      content => template("apt/preferences.erb"),
-      # use File[apt_config] to reference a completed configuration
-      # See "The Puppet Semaphor" 2007-06-25 on the puppet-users ML
-      alias => apt_config,
-      # only update together
-      require => File["/etc/apt/sources.list"];
-    # little default settings which keep the system sane
-    "/etc/apt/apt.conf.d/from_puppet":
-      content => "APT::Get::Show-Upgraded true;\nDSelect::Clean $real_apt_clean;\n",
-      before => Config_file[apt_config];
-  }
-}
index 78ae6c5d4a8cc4b5ce39f8c64511477e87a7e8fd..12096a09403fd3ec7c14b79c36288c4c03fd7715 100644 (file)
@@ -29,18 +29,7 @@ class apt {
     }
   }
 
-  case $custom_preferences {
-    '': {
-      include apt::default_preferences
-    }
-    default: {
-      config_file { "/etc/apt/preferences":
-        content => $custom_preferences,
-        alias => apt_config,
-        require => File["/etc/apt/sources.list"];
-      }
-    }
-  }
+  include apt::preferences
 
   if $apt_unattended_upgrades {
     include apt::unattended_upgrades
@@ -58,13 +47,12 @@ class apt {
       command => '/usr/bin/apt-get update && sleep 1',
       refreshonly => true,
       subscribe => [ File["/etc/apt/sources.list"],
-                     File["/etc/apt/preferences"], 
                      File["/etc/apt/apt.conf.d"],
-                     Config_file[apt_config] ];
+                     Concatenated_file[apt_config] ];
       'update_apt':
         command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
         require => [ File["/etc/apt/sources.list"],
-                     File["/etc/apt/preferences"], Config_file[apt_config] ],
+                     File["/etc/apt/preferences"], Concatenated_file[apt_config] ],
         loglevel => info,
         # Another Semaphor for all packages to reference
         alias => apt_updated;
@@ -88,7 +76,7 @@ class apt {
         alias => "backports_key",
         refreshonly => true,
         subscribe => File["${apt_base_dir}/backports.org.key"],
-        before => [ File[apt_config], Package["debian-backports-keyring"] ]
+        before => [ Concatenated_file[apt_config], Package["debian-backports-keyring"] ]
       }
     }
     lenny: {
@@ -105,7 +93,7 @@ class apt {
         alias => "backports_key",
         refreshonly => true,
         subscribe => File["${apt_base_dir}/backports.org.key"],
-        before => [ Config_file[apt_config], Package["debian-backports-keyring"] ]
+        before => [ Concatenated_file[apt_config], Package["debian-backports-keyring"] ]
       }
     }
   }
@@ -120,7 +108,7 @@ class apt {
       alias => "custom_keys",
       subscribe => File["${apt_base_dir}/keys.d"],
       refreshonly => true,
-      before => Config_file[apt_config];
+      before => Concatenated_file[apt_config];
     }
   }
 
diff --git a/manifests/module_dir.pp b/manifests/module_dir.pp
new file mode 100644 (file)
index 0000000..6dcfca3
--- /dev/null
@@ -0,0 +1,3 @@
+class apt::module_dir {
+  module_dir{'apt': }
+}
diff --git a/manifests/preferences.pp b/manifests/preferences.pp
new file mode 100644 (file)
index 0000000..b106153
--- /dev/null
@@ -0,0 +1,28 @@
+class apt::preferences {
+
+  include apt::module_dir
+  module_dir{'apt/preferences': }
+  concatenated_file{'/etc/apt/preferences':
+    dir => '/var/lib/puppet/modules/apt/preferences',
+    header => 'Package: *
+Pin: release a=unstable
+Pin-Priority: 1
+
+Package: *
+Pin: release a=testing
+Pin-Priority: 2
+',
+    # use Concatenated_file[apt_config] to reference a completed configuration
+    # See "The Puppet Semaphor" 2007-06-25 on the puppet-users ML
+    alias => apt_config,
+    # only update together
+    require => File["/etc/apt/sources.list"];
+  }
+
+  config_file {
+    # little default settings which keep the system sane
+    "/etc/apt/apt.conf.d/from_puppet":
+      content => "APT::Get::Show-Upgraded true;\nDSelect::Clean $real_apt_clean;\n",
+      before => Concatenated_file[apt_config];
+  }
+}
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp
new file mode 100644 (file)
index 0000000..52edf97
--- /dev/null
@@ -0,0 +1,11 @@
+define apt::preferences_snippet(
+  $ensure => 'present',
+  $content
+){
+  file { "/var/lib/puppet/modules/apt/preferences/${name}":
+    ensure => $ensure,
+    content => "${content}\n",
+    notify => Exec['concat_/var/lib/puppet/modules/apt/preferences'],
+    owner => root, group => 0, mode => 0600;
+  }
+}
index c984c409be36f99dc4415075a8383a1d8647ffb2..9a6c13ba3a945a3a0ea261c034d1f84aff7975d8 100644 (file)
@@ -9,7 +9,7 @@ class apt::unattended_upgrades {
       content => 'APT::Periodic::Update-Package-Lists "1";
 APT::Periodic::Unattended-Upgrade "1";
 ',
-      before => Config_file[apt_config],
+      before => Concatenated_file[apt_config],
       require => Package['unattended-upgrades'],
   }
 }