2011-05-30 03:43:01 +02:00
|
|
|
# Class: apt
|
|
|
|
#
|
|
|
|
# This module manages the initial configuration of apt.
|
|
|
|
#
|
|
|
|
# Parameters:
|
2012-02-24 18:27:28 +01:00
|
|
|
# The parameters listed here are not required in general and were
|
2011-05-30 03:43:01 +02:00
|
|
|
# added for use cases related to development environments.
|
|
|
|
# disable_keys - disables the requirement for all packages to be signed
|
|
|
|
# always_apt_update - rather apt should be updated on every run (intended
|
|
|
|
# for development environments where package updates are frequent
|
2012-02-24 18:27:28 +01:00
|
|
|
# purge_sources_list - Accepts true or false. Defaults to false If set to
|
|
|
|
# true, Puppet will purge all unmanaged entries from sources.list"
|
|
|
|
# purge_sources_list_d - Accepts true or false. Defaults to false. If set
|
|
|
|
# to false, Puppet will purge all unmanaged entries from sources.list.d
|
|
|
|
#
|
2011-05-30 03:43:01 +02:00
|
|
|
# Actions:
|
|
|
|
#
|
|
|
|
# Requires:
|
|
|
|
#
|
|
|
|
# Sample Usage:
|
|
|
|
# class { 'apt': }
|
|
|
|
class apt(
|
2012-02-08 18:40:43 +01:00
|
|
|
$always_apt_update = false,
|
2012-02-10 01:18:14 +01:00
|
|
|
$disable_keys = undef,
|
2012-02-08 18:40:43 +01:00
|
|
|
$proxy_host = false,
|
2012-02-08 20:40:09 +01:00
|
|
|
$proxy_port = '8080',
|
2012-02-24 18:27:28 +01:00
|
|
|
$purge_sources_list = false,
|
|
|
|
$purge_sources_list_d = false
|
2011-05-30 03:43:01 +02:00
|
|
|
) {
|
2010-04-27 22:38:28 +02:00
|
|
|
|
2011-05-30 19:18:13 +02:00
|
|
|
include apt::params
|
2012-05-04 22:35:13 +02:00
|
|
|
include apt::update
|
2011-05-30 19:18:13 +02:00
|
|
|
|
2012-02-24 18:27:28 +01:00
|
|
|
validate_bool($purge_sources_list, $purge_sources_list_d)
|
2012-02-08 20:40:09 +01:00
|
|
|
|
2012-03-21 14:35:48 +01:00
|
|
|
$sources_list_content = $purge_sources_list ? {
|
2012-05-03 18:51:14 +02:00
|
|
|
false => undef,
|
2012-03-21 14:35:48 +01:00
|
|
|
true => "# Repos managed by puppet.\n",
|
|
|
|
}
|
2012-04-11 23:54:13 +02:00
|
|
|
|
2012-05-04 22:35:13 +02:00
|
|
|
if $always_apt_update == true {
|
2012-05-04 00:44:17 +02:00
|
|
|
Exec <| title=='apt_update' |> {
|
2012-05-04 22:35:13 +02:00
|
|
|
refreshonly => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-11 23:54:13 +02:00
|
|
|
$root = $apt::params::root
|
|
|
|
$apt_conf_d = $apt::params::apt_conf_d
|
|
|
|
$sources_list_d = $apt::params::sources_list_d
|
|
|
|
$provider = $apt::params::provider
|
|
|
|
|
2012-03-21 14:20:13 +01:00
|
|
|
file { 'sources.list':
|
|
|
|
ensure => present,
|
2012-04-11 23:54:13 +02:00
|
|
|
path => "${root}/sources.list",
|
2012-03-21 14:20:13 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
2012-03-21 14:35:48 +01:00
|
|
|
content => $sources_list_content,
|
2012-05-04 00:44:17 +02:00
|
|
|
notify => Exec['apt_update'],
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
2011-03-11 18:02:50 +01:00
|
|
|
|
2012-03-21 14:20:13 +01:00
|
|
|
file { 'sources.list.d':
|
|
|
|
ensure => directory,
|
2012-04-12 02:49:30 +02:00
|
|
|
path => $sources_list_d,
|
2012-03-21 14:20:13 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
purge => $purge_sources_list_d,
|
2012-02-24 18:27:28 +01:00
|
|
|
recurse => $purge_sources_list_d,
|
2012-05-04 00:44:17 +02:00
|
|
|
notify => Exec['apt_update'],
|
2011-05-30 03:43:01 +02:00
|
|
|
}
|
2012-02-10 01:18:14 +01:00
|
|
|
|
|
|
|
case $disable_keys {
|
|
|
|
true: {
|
2012-03-21 14:20:13 +01:00
|
|
|
file { '99unauth':
|
2012-02-10 01:18:14 +01:00
|
|
|
ensure => present,
|
2012-03-21 14:20:13 +01:00
|
|
|
content => "APT::Get::AllowUnauthenticated 1;\n",
|
2012-04-11 23:54:13 +02:00
|
|
|
path => "${apt_conf_d}/99unauth",
|
2012-02-10 01:18:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
false: {
|
2012-03-21 14:20:13 +01:00
|
|
|
file { '99unauth':
|
2012-02-10 01:18:14 +01:00
|
|
|
ensure => absent,
|
2012-04-11 23:54:13 +02:00
|
|
|
path => "${apt_conf_d}/99unauth",
|
2012-02-10 01:18:14 +01:00
|
|
|
}
|
2011-05-30 03:43:01 +02:00
|
|
|
}
|
2012-05-04 22:35:13 +02:00
|
|
|
undef: { } # do nothing
|
2012-03-21 14:20:13 +01:00
|
|
|
default: { fail('Valid values for disable_keys are true or false') }
|
2011-05-30 03:43:01 +02:00
|
|
|
}
|
2012-02-08 18:40:43 +01:00
|
|
|
|
2012-03-30 17:48:31 +02:00
|
|
|
if ($proxy_host) {
|
2012-02-08 18:40:43 +01:00
|
|
|
file { 'configure-apt-proxy':
|
2012-04-11 23:54:13 +02:00
|
|
|
path => "${apt_conf_d}/proxy",
|
2012-02-08 18:40:43 +01:00
|
|
|
content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";",
|
2012-05-04 00:44:17 +02:00
|
|
|
notify => Exec['apt_update'],
|
2012-02-08 18:40:43 +01:00
|
|
|
}
|
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|