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(
|
2015-02-07 17:12:55 +01:00
|
|
|
$use_lts = $apt::params::use_lts,
|
2013-03-20 22:09:29 +01:00
|
|
|
$use_volatile = $apt::params::use_volatile,
|
2015-06-09 17:25:34 +02:00
|
|
|
$use_backports = $apt::params::use_backports,
|
2013-03-20 22:09:29 +01:00
|
|
|
$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,
|
2015-02-07 17:12:55 +01:00
|
|
|
$lts_url = $apt::params::lts_url,
|
2013-03-20 22:09:29 +01:00
|
|
|
$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,
|
|
|
|
}
|
|
|
|
|
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 {
|
2015-06-11 17:04:46 +02:00
|
|
|
# include main and security
|
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,
|
2016-01-26 14:42:17 +01:00
|
|
|
notify => Exec['apt_updated'],
|
2013-01-02 14:12:11 +01:00
|
|
|
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 }
|
|
|
|
|
2015-10-09 20:08:46 +02:00
|
|
|
if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) {
|
|
|
|
apt::sources_list {
|
|
|
|
'backports':
|
|
|
|
content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}",
|
|
|
|
}
|
|
|
|
if $include_src {
|
2015-06-11 17:04:46 +02:00
|
|
|
apt::sources_list {
|
2015-10-09 20:08:46 +02:00
|
|
|
'backports-src':
|
|
|
|
content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}",
|
2015-06-11 17:04:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-28 14:01:14 +01:00
|
|
|
include common::moduledir
|
2014-01-08 21:28:42 +01:00
|
|
|
common::module_dir { 'apt': }
|
2013-01-02 14:12:11 +01:00
|
|
|
$apt_base_dir = "${common::moduledir::module_dir_path}/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':
|
2015-12-09 16:31:35 +01:00
|
|
|
command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;",
|
2013-01-02 14:12:11 +01:00
|
|
|
subscribe => File["${apt_base_dir}/keys.d"],
|
2010-09-15 22:31:42 +02:00
|
|
|
refreshonly => true,
|
2015-12-09 16:31:35 +01:00
|
|
|
notify => Exec[refresh_apt]
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
|
|
|
if $custom_preferences != false {
|
2013-01-02 14:12:11 +01:00
|
|
|
Exec['custom_keys'] {
|
2015-12-09 16:31:35 +01:00
|
|
|
before => File['apt_config']
|
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 }
|
2016-01-26 14:42:17 +01:00
|
|
|
|
|
|
|
exec { 'update_apt':
|
2016-01-26 14:52:53 +01:00
|
|
|
command => '/usr/bin/apt-get update',
|
2016-01-26 14:42:17 +01:00
|
|
|
require => [
|
|
|
|
File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ],
|
|
|
|
File['/etc/apt/sources.list'] ],
|
|
|
|
loglevel => 'info',
|
|
|
|
refreshonly => true,
|
|
|
|
# Another Semaphor for all packages to reference
|
|
|
|
alias => [ 'apt_updated', 'refresh_apt']
|
|
|
|
}
|
|
|
|
|
2010-10-17 01:57:55 +02:00
|
|
|
}
|