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.
|
|
|
|
|
2012-06-06 02:31:15 +02:00
|
|
|
class apt(
|
2012-06-14 15:07:29 +02:00
|
|
|
$use_volatile = false,
|
|
|
|
$include_src = false,
|
|
|
|
$use_next_release = false,
|
|
|
|
$debian_url = 'http://cdn.debian.net/debian/',
|
|
|
|
$security_url = 'http://security.debian.org/',
|
|
|
|
$backports_url = 'http://backports.debian.org/debian-backports/',
|
|
|
|
$volatile_url = 'http://volatile.debian.org/debian-volatile/',
|
|
|
|
$ubuntu_url = 'http://archive.ubuntu.com/ubuntu',
|
|
|
|
$repos = 'auto',
|
|
|
|
$custom_preferences = ''
|
|
|
|
){
|
2012-06-06 02:31:15 +02:00
|
|
|
case $::operatingsystem {
|
2010-10-17 02:01:48 +02:00
|
|
|
'debian': {
|
2012-06-06 02:31:15 +02:00
|
|
|
$real_repos = $repos ? {
|
|
|
|
'auto' => 'main contrib non-free',
|
|
|
|
default => $repos,
|
2010-10-17 02:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'ubuntu': {
|
2012-06-06 02:31:15 +02:00
|
|
|
$real_repos = $repos ? {
|
2010-10-17 02:01:48 +02:00
|
|
|
'' => 'main restricted universe multiverse',
|
2012-06-06 02:31:15 +02:00
|
|
|
default => $repos,
|
2010-10-17 02:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
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-24 13:32:14 +02:00
|
|
|
include lsb
|
2010-11-21 16:24:57 +01:00
|
|
|
|
2010-12-12 09:43:40 +01:00
|
|
|
# init $release, $next_release, $codename, $next_codename, $release_version
|
2012-06-06 02:31:15 +02:00
|
|
|
case $::lsbdistcodename {
|
2010-10-06 11:52:07 +02:00
|
|
|
'': {
|
2012-06-06 02:31:15 +02:00
|
|
|
$release = $::lsbdistrelease
|
2010-10-06 11:52:07 +02:00
|
|
|
}
|
|
|
|
default: {
|
2012-06-08 17:16:46 +02:00
|
|
|
$release = debian_release($::lsbdistcodename)
|
2010-10-06 11:52:07 +02:00
|
|
|
}
|
2010-10-06 11:17:30 +02:00
|
|
|
}
|
2012-06-08 17:16:46 +02:00
|
|
|
$release_version = debian_release_version($::lsbdistcodename)
|
|
|
|
$next_codename = debian_nextcodename($::lsbdistcodename)
|
2010-10-06 11:17:30 +02:00
|
|
|
$next_release = debian_nextrelease($release)
|
|
|
|
|
2012-06-18 16:41:04 +02:00
|
|
|
file {
|
2010-10-25 06:14:33 +02:00
|
|
|
# include main, security and backports
|
2010-10-25 07:44:04 +02:00
|
|
|
# additional sources should be included via the apt::sources_list define
|
2010-10-25 06:14:33 +02:00
|
|
|
"/etc/apt/sources.list":
|
|
|
|
content => $custom_sources_list ? {
|
2012-06-06 02:31:15 +02:00
|
|
|
'' => template( "apt/${::operatingsystem}/sources.list.erb"),
|
2010-10-25 06:14:33 +02:00
|
|
|
default => $custom_sources_list
|
|
|
|
},
|
2012-04-09 07:39:29 +02:00
|
|
|
require => Package['lsb'],
|
|
|
|
notify => Exec['refresh_apt'],
|
2012-06-18 16:41:04 +02:00
|
|
|
owner => root, group => 0, mode => 0644;
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
|
2010-10-25 07:44:04 +02:00
|
|
|
apt_conf { "02show_upgraded":
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded",
|
2012-04-15 15:41:58 +02:00
|
|
|
"puppet:///modules/site_apt/02show_upgraded",
|
2010-12-07 19:18:41 +01:00
|
|
|
"puppet:///modules/apt/02show_upgraded" ]
|
2010-10-24 15:07:34 +02:00
|
|
|
}
|
|
|
|
|
2012-06-06 02:31:15 +02:00
|
|
|
if ( $::virtual == "vserver" ) {
|
2010-12-07 18:20:14 +01:00
|
|
|
apt_conf { "03clean_vserver":
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver",
|
2012-04-15 15:41:58 +02:00
|
|
|
"puppet:///modules/site_apt/03clean_vserver",
|
2010-12-08 15:57:02 +01:00
|
|
|
"puppet:///modules/apt/03clean_vserver" ],
|
|
|
|
alias => "03clean";
|
2010-12-07 18:20:14 +01:00
|
|
|
}
|
2010-10-18 02:36:45 +02:00
|
|
|
}
|
2010-12-07 18:20:14 +01:00
|
|
|
else {
|
|
|
|
apt_conf { "03clean":
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/03clean",
|
2012-04-15 15:41:58 +02:00
|
|
|
"puppet:///modules/site_apt/03clean",
|
2010-12-07 19:18:41 +01:00
|
|
|
"puppet:///modules/apt/03clean" ]
|
2010-12-07 18:20:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-30 18:21:42 +01:00
|
|
|
case $custom_preferences {
|
2010-10-18 07:45:22 +02:00
|
|
|
false: {
|
2010-10-21 01:59:41 +02:00
|
|
|
include apt::preferences::absent
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
default: {
|
2010-10-25 18:32:49 +02:00
|
|
|
# When squeeze becomes the stable branch, transform this file's header
|
|
|
|
# into a preferences.d file
|
2010-10-21 01:59:41 +02:00
|
|
|
include apt::preferences
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
}
|
2007-06-25 11:50:19 +02:00
|
|
|
|
2012-04-09 07:33:13 +02:00
|
|
|
include apt::dot_d_directories
|
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-10-25 17:44:41 +02:00
|
|
|
include common::moduledir
|
|
|
|
$apt_base_dir = "${common::moduledir::module_dir_path}/apt"
|
|
|
|
modules_dir { apt: }
|
|
|
|
|
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-12-08 05:06:11 +01:00
|
|
|
exec { "custom_keys":
|
2010-12-14 21:56:36 +01:00
|
|
|
command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\; && /usr/bin/apt-get update",
|
2010-09-15 22:31:42 +02:00
|
|
|
subscribe => File["${apt_base_dir}/keys.d"],
|
|
|
|
refreshonly => true,
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
|
|
|
if $custom_preferences != false {
|
|
|
|
Exec["custom_keys"] {
|
2011-08-05 11:22:05 +02:00
|
|
|
before => Concat[apt_config],
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
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
|
|
|
}
|