From 4d28e6668f0c26d7484198c1cdf418c83898b3c7 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 17 Oct 2010 13:58:59 +0200 Subject: introduce preferences snippet 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. --- manifests/default_preferences.pp | 16 ---------------- manifests/init.pp | 24 ++++++------------------ manifests/module_dir.pp | 3 +++ manifests/preferences.pp | 28 ++++++++++++++++++++++++++++ manifests/preferences_snippet.pp | 11 +++++++++++ manifests/unattended_upgrades.pp | 2 +- 6 files changed, 49 insertions(+), 35 deletions(-) delete mode 100644 manifests/default_preferences.pp create mode 100644 manifests/module_dir.pp create mode 100644 manifests/preferences.pp create mode 100644 manifests/preferences_snippet.pp (limited to 'manifests') diff --git a/manifests/default_preferences.pp b/manifests/default_preferences.pp deleted file mode 100644 index 3cdb355..0000000 --- a/manifests/default_preferences.pp +++ /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]; - } -} diff --git a/manifests/init.pp b/manifests/init.pp index 78ae6c5..12096a0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 index 0000000..6dcfca3 --- /dev/null +++ b/manifests/module_dir.pp @@ -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 index 0000000..b106153 --- /dev/null +++ b/manifests/preferences.pp @@ -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 index 0000000..52edf97 --- /dev/null +++ b/manifests/preferences_snippet.pp @@ -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; + } +} diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index c984c40..9a6c13b 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -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'], } } -- cgit v1.2.3