2011-05-30 03:43:01 +02:00
|
|
|
#
|
|
|
|
class apt(
|
2012-05-22 00:48:00 +02:00
|
|
|
$always_apt_update = false,
|
2014-08-18 22:12:55 +02:00
|
|
|
$apt_update_frequency = 'reluctantly',
|
2012-05-22 00:48:00 +02:00
|
|
|
$purge_sources_list = false,
|
2012-05-22 00:51:33 +02:00
|
|
|
$purge_sources_list_d = false,
|
2014-02-22 10:56:50 +01:00
|
|
|
$purge_preferences = false,
|
2013-10-02 14:24:30 +02:00
|
|
|
$purge_preferences_d = false,
|
2013-12-04 19:05:26 +01:00
|
|
|
$update_timeout = undef,
|
2014-03-05 22:59:21 +01:00
|
|
|
$update_tries = undef,
|
2014-04-24 09:52:12 +02:00
|
|
|
$sources = undef,
|
2015-02-15 18:09:47 +01:00
|
|
|
) inherits ::apt::params {
|
2010-04-27 22:38:28 +02:00
|
|
|
|
2015-02-15 18:09:47 +01:00
|
|
|
include apt::update
|
|
|
|
|
2014-08-18 22:12:55 +02:00
|
|
|
$frequency_options = ['always','daily','weekly','reluctantly']
|
|
|
|
validate_re($apt_update_frequency, $frequency_options)
|
2011-05-30 19:18:13 +02:00
|
|
|
|
2014-02-22 10:56:50 +01:00
|
|
|
validate_bool($purge_sources_list, $purge_sources_list_d,
|
|
|
|
$purge_preferences, $purge_preferences_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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 23:57:31 +01:00
|
|
|
apt::setting { 'conf-update-stamp':
|
2015-02-26 19:12:53 +01:00
|
|
|
priority => 15,
|
|
|
|
content => template('apt/_header.erb', 'apt/15update-stamp.erb'),
|
2014-08-18 22:12:55 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 14:20:13 +01:00
|
|
|
file { 'sources.list':
|
|
|
|
ensure => present,
|
2015-02-20 00:09:44 +01:00
|
|
|
path => $::apt::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,
|
2015-02-20 00:09:44 +01:00
|
|
|
path => $::apt::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
|
|
|
|
2014-05-05 12:06:39 +02:00
|
|
|
if $purge_preferences {
|
2014-05-02 23:35:54 +02:00
|
|
|
file { 'apt-preferences':
|
2014-09-05 18:51:39 +02:00
|
|
|
ensure => absent,
|
2015-02-20 00:09:44 +01:00
|
|
|
path => $::apt::preferences,
|
2014-05-02 23:35:54 +02:00
|
|
|
}
|
2014-02-22 10:56:50 +01:00
|
|
|
}
|
|
|
|
|
2012-05-22 00:51:33 +02:00
|
|
|
file { 'preferences.d':
|
|
|
|
ensure => directory,
|
2015-02-20 00:09:44 +01:00
|
|
|
path => $::apt::preferences_d,
|
2012-05-22 00:51:33 +02:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
purge => $purge_preferences_d,
|
|
|
|
recurse => $purge_preferences_d,
|
|
|
|
}
|
|
|
|
|
2012-05-08 00:27:53 +02:00
|
|
|
# Need anchor to provide containment for dependencies.
|
2012-08-21 22:55:24 +02:00
|
|
|
anchor { 'apt::update':
|
2012-05-08 00:27:53 +02:00
|
|
|
require => Class['apt::update'],
|
|
|
|
}
|
2013-12-04 19:05:26 +01:00
|
|
|
|
|
|
|
# manage sources if present
|
|
|
|
if $sources != undef {
|
2014-03-27 17:40:36 +01:00
|
|
|
validate_hash($sources)
|
|
|
|
create_resources('apt::source', $sources)
|
2013-12-04 19:05:26 +01:00
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|