2007-06-25 11:50:19 +02:00
|
|
|
# apt.pp - common components and defaults for handling apt
|
2008-09-29 22:27:18 +02:00
|
|
|
# Copyright (C) 2008 Micah Anerson <micah@riseup.net>
|
2007-06-25 11:50:19 +02:00
|
|
|
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
|
|
|
|
# See LICENSE for the full license granted to you.
|
|
|
|
|
|
|
|
class apt {
|
|
|
|
|
2010-10-09 14:39:11 +02:00
|
|
|
import "custom_sources.pp"
|
2010-10-17 01:57:55 +02:00
|
|
|
|
2009-10-30 18:21:42 +01:00
|
|
|
# See README
|
|
|
|
$real_apt_clean = $apt_clean ? {
|
|
|
|
'' => 'auto',
|
|
|
|
default => $apt_clean,
|
|
|
|
}
|
|
|
|
|
2010-10-17 01:12:19 +02:00
|
|
|
$use_volatile = $apt_volatile_enabled ? {
|
2010-10-06 12:00:32 +02:00
|
|
|
'' => false,
|
2010-10-17 01:12:19 +02:00
|
|
|
default => $apt_volatile_enabled,
|
2010-10-06 12:00:32 +02:00
|
|
|
}
|
|
|
|
|
2010-10-06 12:09:38 +02:00
|
|
|
$include_src = $apt_include_src ? {
|
|
|
|
'' => false,
|
|
|
|
default => $apt_include_src,
|
|
|
|
}
|
|
|
|
|
2010-10-06 12:39:50 +02:00
|
|
|
$use_next_release = $apt_use_next_release ? {
|
|
|
|
'' => false,
|
|
|
|
default => $apt_use_next_release,
|
|
|
|
}
|
|
|
|
|
2010-10-06 13:29:38 +02:00
|
|
|
$debian_url = $apt_debian_url ? {
|
|
|
|
'' => 'http://ftp.debian.org/debian/',
|
|
|
|
default => "${apt_debian_url}",
|
|
|
|
}
|
|
|
|
$security_url = $apt_security_url ? {
|
|
|
|
'' => 'http://security.debian.org/',
|
|
|
|
default => "${apt_security_url}",
|
|
|
|
}
|
|
|
|
$backports_url = $apt_backports_url ? {
|
|
|
|
'' => 'http://backports.debian.org/debian-backports/',
|
|
|
|
default => "${apt_backports_url}",
|
|
|
|
}
|
|
|
|
$volatile_url = $apt_volatile_url ? {
|
|
|
|
'' => 'http://volatile.debian.org/debian-volatile/',
|
|
|
|
default => "${apt_volatile_url}",
|
|
|
|
}
|
2010-10-17 10:51:06 +02:00
|
|
|
$ubuntu_url = $apt_ubuntu_url ? {
|
|
|
|
'' => 'http://archive.ubuntu.com/ubuntu',
|
|
|
|
default => "${apt_ubuntu_url}",
|
|
|
|
}
|
2010-10-17 02:01:48 +02:00
|
|
|
case $operatingsystem {
|
|
|
|
'debian': {
|
|
|
|
$repos = $apt_repos ? {
|
|
|
|
'' => 'main contrib non-free',
|
|
|
|
default => "${apt_repos}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'ubuntu': {
|
|
|
|
$repos = $apt_repos ? {
|
|
|
|
'' => 'main restricted universe multiverse',
|
|
|
|
default => "${apt_repos}",
|
|
|
|
}
|
|
|
|
}
|
2010-10-10 11:06:07 +02:00
|
|
|
}
|
2010-10-06 13:29:38 +02:00
|
|
|
|
2010-10-06 12:09:38 +02:00
|
|
|
package { apt:
|
|
|
|
ensure => installed,
|
|
|
|
require => undef,
|
|
|
|
}
|
|
|
|
|
2010-10-06 11:17:30 +02:00
|
|
|
# init $release, $next_release, $codename, $next_codename
|
|
|
|
case $lsbdistcodename {
|
2010-10-06 11:52:07 +02:00
|
|
|
'': {
|
|
|
|
include lsb
|
|
|
|
$codename = $lsbdistcodename
|
|
|
|
$release = $lsbdistrelease
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
$codename = $lsbdistcodename
|
|
|
|
$release = debian_release($codename)
|
|
|
|
}
|
2010-10-06 11:17:30 +02:00
|
|
|
}
|
|
|
|
$next_codename = debian_nextcodename($codename)
|
|
|
|
$next_release = debian_nextrelease($release)
|
|
|
|
|
2009-10-30 18:21:42 +01:00
|
|
|
case $custom_sources_list {
|
|
|
|
'': {
|
|
|
|
include apt::default_sources_list
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
config_file { "/etc/apt/sources.list":
|
|
|
|
content => $custom_sources_list,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case $custom_preferences {
|
|
|
|
'': {
|
|
|
|
include apt::default_preferences
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
config_file { "/etc/apt/preferences":
|
|
|
|
content => $custom_preferences,
|
2010-09-03 01:14:23 +02:00
|
|
|
alias => "apt_config",
|
2009-10-30 18:21:42 +01:00
|
|
|
require => File["/etc/apt/sources.list"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-25 11:50:19 +02:00
|
|
|
|
2010-10-17 02:21:08 +02:00
|
|
|
config_file { '/etc/apt/apt.conf.d/99from_puppet': }
|
|
|
|
# little default settings which keep the system sane
|
2010-10-17 02:54:20 +02:00
|
|
|
append_if_no_such_line { 'apt-get-show-upgraded':
|
2010-10-17 02:21:08 +02:00
|
|
|
file => "/etc/apt/apt.conf.d/99from_puppet",
|
|
|
|
line => "APT::Get::Show-Upgraded true;",
|
|
|
|
before => Config_file[apt_config],
|
|
|
|
require => Config_file['/etc/apt/apt.conf.d/99from_puppet'],
|
|
|
|
}
|
2010-10-17 02:54:20 +02:00
|
|
|
append_if_no_such_line { 'dselect-clean':
|
2010-10-17 02:21:08 +02:00
|
|
|
file => "/etc/apt/apt.conf.d/99from_puppet",
|
|
|
|
line => "DSelect::Clean ${real_apt_clean};",
|
|
|
|
before => Config_file[apt_config],
|
|
|
|
require => Config_file['/etc/apt/apt.conf.d/99from_puppet'],
|
2010-10-17 02:11:41 +02:00
|
|
|
}
|
2010-10-17 02:13:59 +02:00
|
|
|
# backward compatibility: upgrade from previous versions of this module.
|
|
|
|
file {
|
|
|
|
"/etc/apt/apt.conf.d/from_puppet":
|
|
|
|
ensure => 'absent',
|
2010-10-17 02:54:20 +02:00
|
|
|
require => [ Append_if_no_such_line['apt-get-show-upgraded'],
|
|
|
|
Append_if_no_such_line['dselect-clean']
|
|
|
|
],
|
2010-10-17 02:13:59 +02:00
|
|
|
}
|
2010-10-17 02:11:41 +02:00
|
|
|
|
2009-10-30 20:35:30 +01:00
|
|
|
if $apt_unattended_upgrades {
|
|
|
|
include apt::unattended_upgrades
|
|
|
|
}
|
|
|
|
|
2010-05-09 22:44:40 +02:00
|
|
|
include common::moduledir
|
|
|
|
$apt_base_dir = "${common::moduledir::module_dir_path}/apt"
|
2009-10-30 21:43:43 +01:00
|
|
|
modules_dir { apt: }
|
2009-10-30 18:21:42 +01:00
|
|
|
# watch apt.conf.d
|
|
|
|
file { "/etc/apt/apt.conf.d": ensure => directory, checksum => mtime; }
|
|
|
|
|
|
|
|
exec {
|
|
|
|
# "&& sleep 1" is workaround for older(?) clients
|
2010-08-10 16:27:54 +02:00
|
|
|
'refresh_apt':
|
|
|
|
command => '/usr/bin/apt-get update && sleep 1',
|
2009-10-30 18:21:42 +01:00
|
|
|
refreshonly => true,
|
2010-09-03 01:15:47 +02:00
|
|
|
subscribe => [ File["/etc/apt/sources.list", "/etc/apt/preferences", "/etc/apt/apt.conf.d"],
|
2010-09-03 01:14:23 +02:00
|
|
|
Config_file["apt_config"] ];
|
2010-08-10 16:27:54 +02:00
|
|
|
'update_apt':
|
|
|
|
command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
|
2010-09-03 01:15:47 +02:00
|
|
|
require => [ File["/etc/apt/sources.list", "/etc/apt/preferences"], Config_file["apt_config"] ],
|
2010-06-28 21:49:09 +02:00
|
|
|
loglevel => info,
|
2009-10-30 18:21:42 +01:00
|
|
|
# Another Semaphor for all packages to reference
|
2010-09-03 01:14:23 +02:00
|
|
|
alias => "apt_updated";
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
## This package should really always be current
|
|
|
|
package { "debian-archive-keyring": ensure => latest }
|
2010-09-09 00:39:33 +02:00
|
|
|
# backports uses the normal archive key now
|
|
|
|
package { "debian-backports-keyring": ensure => absent }
|
2009-10-30 18:21:42 +01:00
|
|
|
|
2010-09-15 22:31:42 +02:00
|
|
|
if $custom_key_dir {
|
|
|
|
file { "${apt_base_dir}/keys.d":
|
|
|
|
source => "$custom_key_dir",
|
|
|
|
recurse => true,
|
|
|
|
mode => 0755, owner => root, group => root,
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
2010-09-15 22:31:42 +02:00
|
|
|
exec { "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\; && apt-get update":
|
|
|
|
alias => "custom_keys",
|
|
|
|
subscribe => File["${apt_base_dir}/keys.d"],
|
|
|
|
refreshonly => true,
|
|
|
|
before => Config_file[apt_config];
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# workaround for preseeded_package component
|
2010-09-15 22:31:42 +02:00
|
|
|
file { [ "/var/cache", "/var/cache/local", "/var/cache/local/preseeding" ]: ensure => directory }
|
2010-10-17 01:57:55 +02:00
|
|
|
}
|