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(
|
2013-03-20 22:09:29 +01:00
|
|
|
$codename = $apt::params::codename,
|
|
|
|
$use_volatile = $apt::params::use_volatile,
|
|
|
|
$include_src = $apt::params::include_src,
|
|
|
|
$use_next_release = $apt::params::use_next_release,
|
|
|
|
$debian_url = $apt::params::debian_url,
|
|
|
|
$security_url = $apt::params::security_url,
|
|
|
|
$backports_url = $apt::params::backports_url,
|
|
|
|
$volatile_url = $apt::params::volatile_url,
|
|
|
|
$ubuntu_url = $apt::params::ubuntu_url,
|
|
|
|
$repos = $apt::params::repos,
|
|
|
|
$custom_preferences = $apt::params::custom_preferences,
|
2013-07-27 12:14:47 +02:00
|
|
|
$custom_sources_list = '',
|
2013-01-26 18:20:30 +01:00
|
|
|
$disable_update = $apt::params::disable_update,
|
|
|
|
$custom_key_dir = $apt::params::custom_key_dir
|
2013-03-20 22:09:29 +01:00
|
|
|
) inherits apt::params {
|
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 ? {
|
2013-01-02 14:12:11 +01:00
|
|
|
'auto' => 'main contrib non-free',
|
2012-06-06 02:31:15 +02:00
|
|
|
default => $repos,
|
2010-10-17 02:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'ubuntu': {
|
2012-06-06 02:31:15 +02:00
|
|
|
$real_repos = $repos ? {
|
2013-03-05 09:39:23 +01:00
|
|
|
'auto' => '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
|
|
|
|
2013-01-02 14:12:11 +01:00
|
|
|
package { 'apt':
|
|
|
|
ensure => installed,
|
2010-10-06 12:09:38 +02:00
|
|
|
require => undef,
|
|
|
|
}
|
|
|
|
|
2010-10-24 13:32:14 +02:00
|
|
|
include lsb
|
2010-11-21 16:24:57 +01:00
|
|
|
|
2013-01-02 16:54:03 +01:00
|
|
|
# init $release, $next_release, $next_codename, $release_version
|
2012-12-05 19:46:23 +01:00
|
|
|
case $codename {
|
2012-12-18 22:45:38 +01:00
|
|
|
'n/a': {
|
2013-01-02 14:12:11 +01:00
|
|
|
fail("Unknown lsbdistcodename reported by facter: '$::lsbdistcodename', please fix this by setting this variable in your manifest.")
|
2013-01-02 16:14:06 +01:00
|
|
|
}
|
2010-10-06 11:52:07 +02:00
|
|
|
default: {
|
|
|
|
$release = debian_release($codename)
|
|
|
|
}
|
2010-10-06 11:17:30 +02:00
|
|
|
}
|
2010-12-12 09:43:40 +01:00
|
|
|
$release_version = debian_release_version($codename)
|
2010-10-06 11:17:30 +02:00
|
|
|
$next_codename = debian_nextcodename($codename)
|
|
|
|
$next_release = debian_nextrelease($release)
|
|
|
|
|
2013-07-27 12:14:47 +02:00
|
|
|
$sources_content = $custom_sources_list ? {
|
2013-01-02 14:12:11 +01:00
|
|
|
'' => template( "apt/${::operatingsystem}/sources.list.erb"),
|
2013-07-27 12:14:47 +02:00
|
|
|
default => $custom_sources_list
|
2013-01-02 14:12:11 +01:00
|
|
|
}
|
2012-09-20 08:54:26 +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
|
2013-01-02 14:12:11 +01:00
|
|
|
'/etc/apt/sources.list':
|
|
|
|
content => $sources_content,
|
2012-04-09 07:39:29 +02:00
|
|
|
require => Package['lsb'],
|
2013-01-02 14:12:11 +01:00
|
|
|
notify => Exec['refresh_apt'],
|
|
|
|
owner => root,
|
|
|
|
group => 0,
|
|
|
|
mode => '0644';
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
|
2013-01-02 14:12:11 +01:00
|
|
|
apt_conf { '02show_upgraded':
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded",
|
2013-01-02 14:12:11 +01:00
|
|
|
'puppet:///modules/site_apt/02show_upgraded',
|
|
|
|
'puppet:///modules/apt/02show_upgraded' ]
|
2010-10-24 15:07:34 +02:00
|
|
|
}
|
|
|
|
|
2013-01-02 14:12:11 +01:00
|
|
|
if ( $::virtual == 'vserver' ) {
|
|
|
|
apt_conf { '03clean_vserver':
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver",
|
2013-01-02 14:12:11 +01:00
|
|
|
'puppet:///modules/site_apt/03clean_vserver',
|
|
|
|
'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 {
|
2013-01-02 14:12:11 +01:00
|
|
|
apt_conf { '03clean':
|
2012-06-06 02:31:15 +02:00
|
|
|
source => [ "puppet:///modules/site_apt/${::fqdn}/03clean",
|
2013-01-02 14:12:11 +01:00
|
|
|
'puppet:///modules/site_apt/03clean',
|
|
|
|
'puppet:///modules/apt/03clean' ]
|
2010-12-07 18:20:14 +01:00
|
|
|
}
|
|
|
|
}
|
2013-01-02 14:12:11 +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
|
2013-01-02 14:12:11 +01:00
|
|
|
package { 'debian-archive-keyring': ensure => latest }
|
2009-10-30 18:21:42 +01:00
|
|
|
|
2010-09-09 00:39:33 +02:00
|
|
|
# backports uses the normal archive key now
|
2013-01-02 14:12:11 +01:00
|
|
|
package { 'debian-backports-keyring': ensure => absent }
|
|
|
|
|
|
|
|
include common::moduledir
|
|
|
|
$apt_base_dir = "${common::moduledir::module_dir_path}/apt"
|
|
|
|
modules_dir { 'apt': }
|
2009-10-30 18:21:42 +01:00
|
|
|
|
2013-01-26 18:20:30 +01:00
|
|
|
if $custom_key_dir {
|
2010-09-15 22:31:42 +02:00
|
|
|
file { "${apt_base_dir}/keys.d":
|
2013-01-26 18:20:30 +01:00
|
|
|
source => $custom_key_dir,
|
2010-09-15 22:31:42 +02:00
|
|
|
recurse => true,
|
2013-01-02 14:12:11 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0755',
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
2013-01-02 14:12:11 +01:00
|
|
|
exec { 'custom_keys':
|
|
|
|
command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\; && /usr/bin/apt-get update",
|
|
|
|
subscribe => File["${apt_base_dir}/keys.d"],
|
2010-09-15 22:31:42 +02:00
|
|
|
refreshonly => true,
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
|
|
|
if $custom_preferences != false {
|
2013-01-02 14:12:11 +01:00
|
|
|
Exec['custom_keys'] {
|
2013-03-14 20:01:35 +01:00
|
|
|
before => [ Exec[refresh_apt], File['apt_config'] ]
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Exec['custom_keys'] {
|
|
|
|
before => Exec[refresh_apt]
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
2009-10-30 18:21:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# workaround for preseeded_package component
|
2013-01-02 14:12:11 +01:00
|
|
|
file { [ '/var/cache', '/var/cache/local', '/var/cache/local/preseeding' ]: ensure => directory }
|
2010-10-17 01:57:55 +02:00
|
|
|
}
|