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
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
=========
+++ /dev/null
-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];
- }
-}
}
}
- 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
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;
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: {
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"] ]
}
}
}
alias => "custom_keys",
subscribe => File["${apt_base_dir}/keys.d"],
refreshonly => true,
- before => Config_file[apt_config];
+ before => Concatenated_file[apt_config];
}
}
--- /dev/null
+class apt::module_dir {
+ module_dir{'apt': }
+}
--- /dev/null
+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];
+ }
+}
--- /dev/null
+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;
+ }
+}
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'],
}
}