Merge remote branch 'nadir/master'

Conflicts:
	README
	manifests/custom_sources.pp
	manifests/default_preferences.pp
	manifests/init.pp
	manifests/unattended_upgrades.pp
	templates/Debian/sources.list.volatile.erb
This commit is contained in:
intrigeri 2010-11-10 10:11:18 +01:00
commit 2cd9496999
9 changed files with 112 additions and 44 deletions

24
README
View file

@ -67,6 +67,10 @@ example, setting the following variable before including this class
will pull in the templates/apt/preferences file:
$custom_preferences = 'template("apt/preferences")'
Also, if you need the preferences file to be absent, set this variable to false:
$custom_preferences = false
$custom_key_dir
---------------
If you have different apt-key files that you want to get added to your
@ -144,11 +148,27 @@ apt::cron::dist-upgrade
This class sets up cron-apt so that it dist-upgrades the system and
email when upgrades are performed.
Defines
=======
apt::preferences_snippet
------------------------
A way to add pinning information to /etc/apt/preferences
Example:
apt::preferences_snippet{
'irssi-plugin-otr':
release => 'lenny-backports',
priority => 999;
}
Resources
=========
File[apt_config]
----------------
Concatenated_file[apt_config]
-----------------------------
Use this resource to depend on or add to a completed apt configuration
Exec[apt_updated]

View file

@ -1,10 +1,7 @@
define apt::custom_sources_template ($sources_file = "") {
file { "/etc/apt/sources.list.d/$sources_file":
content => template($name),
notify => Exec['refresh_apt']
}
exec { "/usr/bin/apt-get update":
subscribe => File["/etc/apt/sources.list.d/$sources_file"],
refreshonly => true,
}
}
}

View file

@ -1,18 +0,0 @@
class apt::default_preferences {
case $operatingsystem {
'debian': {
config_file {
"/etc/apt/preferences":
content => template("apt/${operatingsystem}/preferences_${codename}.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"];
}
}
'ubuntu': {
notice('There is no support for default Ubuntu APT preferences')
}
}
}

View file

@ -6,7 +6,7 @@
class apt {
import "custom_sources.pp"
# See README
$real_apt_clean = $apt_clean ? {
'' => 'auto',
@ -95,15 +95,11 @@ class apt {
}
case $custom_preferences {
'': {
include apt::default_preferences
false: {
include apt::preferences::absent
}
default: {
config_file { "/etc/apt/preferences":
content => $custom_preferences,
alias => "apt_config",
require => Config_file["/etc/apt/sources.list"];
}
include apt::preferences
}
}
@ -112,13 +108,13 @@ class apt {
append_if_no_such_line { 'apt-get-show-upgraded':
file => "/etc/apt/apt.conf.d/99from_puppet",
line => "APT::Get::Show-Upgraded true;",
before => Config_file[apt_config],
before => Concatenated_file['/etc/apt/preferences'],
require => Config_file['/etc/apt/apt.conf.d/99from_puppet'],
}
append_if_no_such_line { 'dselect-clean':
file => "/etc/apt/apt.conf.d/99from_puppet",
line => "DSelect::Clean ${real_apt_clean};",
before => Config_file[apt_config],
before => Concatenated_file['/etc/apt/preferences'],
require => Config_file['/etc/apt/apt.conf.d/99from_puppet'],
}
# backward compatibility: upgrade from previous versions of this module.
@ -145,12 +141,13 @@ class apt {
'refresh_apt':
command => '/usr/bin/apt-get update && sleep 1',
refreshonly => true,
subscribe => [ File["/etc/apt/apt.conf.d"],
Config_file["/etc/apt/sources.list"] ];
subscribe => [ File['/etc/apt/apt.conf.d'],
Config_file['/etc/apt/sources.list'] ];
'update_apt':
command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
require => [ File["/etc/apt/apt.conf.d"],
Config_file["/etc/apt/sources.list"] ],
require => [ File['/etc/apt/apt.conf.d',
'/etc/apt/preferences'],
Config_file['/etc/apt/sources.list'] ],
loglevel => info,
# Another Semaphor for all packages to reference
alias => "apt_updated";
@ -158,6 +155,7 @@ class apt {
## This package should really always be current
package { "debian-archive-keyring": ensure => latest }
# backports uses the normal archive key now
package { "debian-backports-keyring": ensure => absent }
@ -171,7 +169,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];
}
}

26
manifests/preferences.pp Normal file
View file

@ -0,0 +1,26 @@
class apt::preferences {
include common::moduledir
$apt_preferences_dir = "${common::moduledir::module_dir_path}/apt/preferences"
module_dir{'apt/preferences': }
file{"${apt_preferences_dir}_header":
content => $custom_preferences ? {
'' => $operatingsystem ? {
'debian' => template("apt/${operatingsystem}/preferences_${codename}.erb"),
'ubuntu' => '',
},
default => $custom_preferences
},
}
concatenated_file{'/etc/apt/preferences':
dir => $apt_preferences_dir,
header => "${apt_preferences_dir}_header",
# 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"];
}
}

View file

@ -0,0 +1,8 @@
class apt::preferences::absent {
include common::moduledir
$apt_preferences_dir = "${common::moduledir::module_dir_path}/apt/preferences"
concatenated_file{'/etc/apt/preferences':
dir => $apt_preferences_dir,
ensure => absent,
}
}

View file

@ -0,0 +1,17 @@
define apt::preferences_snippet(
$ensure = 'present',
$release,
$priority
){
include apt::preferences
file { "${apt::preferences::apt_preferences_dir}/${name}":
ensure => $ensure,
content => "Package: ${name}
Pin: release a=${release}
Pin-Priority: ${priority}
",
notify => Exec["concat_${apt::preferences::apt_preferences_dir}"],
owner => root, group => 0, mode => 0600;
}
}

18
manifests/proxy-client.pp Normal file
View file

@ -0,0 +1,18 @@
class apt::proxy-client {
$real_apt_proxy = $apt_proxy ? {
"" => "localhost",
default => $apt_proxy
}
$real_apt_proxy_port = $apt_proxy_port ? {
"" => "3142",
default => $apt_proxy_port
}
file { "/etc/apt/apt.conf.d/20proxy":
ensure => present,
content => "Acquire::http { Proxy \"http://$real_apt_proxy:$real_apt_proxy_port\"; };\n",
owner => root, group => 0, mode => 0644;
}
}

View file

@ -5,11 +5,13 @@ class apt::unattended_upgrades {
}
config_file {
"/etc/apt/apt.conf.d/50unattended-upgrades":
source => ["puppet:///modules/site-apt/50unattended-upgrades",
"puppet:///modules/apt/50unattended-upgrades" ],
"/etc/apt/apt.conf.d/50unattended-upgrades":
source => ["puppet:///modules/site-apt/50unattended-upgrades",
"puppet:///modules/apt/50unattended-upgrades" ],
before => Config_file[apt_config],
# err: Could not run Puppet configuration client: Could not find dependent Config_file[apt_config] for Config_file[/etc/apt/apt.conf.d/50unattended-upgrades] at /etc/puppet/modules/apt/manifests/unattended_upgrades.pp:14
#before => Config_file[apt_config],
require => Package['unattended-upgrades'],
}
}