aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/apt_conf.pp2
-rw-r--r--manifests/apticron.pp2
-rw-r--r--manifests/dist_upgrade.pp11
-rw-r--r--manifests/dot_d_directories.pp11
-rw-r--r--manifests/dselect.pp9
-rw-r--r--manifests/init.pp65
-rw-r--r--manifests/key.pp13
-rw-r--r--manifests/key/plain.pp13
-rw-r--r--manifests/listchanges.pp2
-rw-r--r--manifests/params.pp18
-rw-r--r--manifests/preferences.pp4
-rw-r--r--manifests/preferences_snippet.pp8
-rw-r--r--manifests/preseeded_package.pp2
-rw-r--r--manifests/sources_list.pp10
-rw-r--r--manifests/unattended_upgrades.pp45
-rw-r--r--manifests/update.pp12
-rw-r--r--manifests/upgrade_package.pp15
17 files changed, 124 insertions, 118 deletions
diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp
index f446c69..949f615 100644
--- a/manifests/apt_conf.pp
+++ b/manifests/apt_conf.pp
@@ -38,7 +38,7 @@ define apt::apt_conf(
if $refresh_apt {
File["/etc/apt/apt.conf.d/${name}"] {
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
}
}
diff --git a/manifests/apticron.pp b/manifests/apticron.pp
index 54d7b71..9c94f9c 100644
--- a/manifests/apticron.pp
+++ b/manifests/apticron.pp
@@ -1,6 +1,6 @@
class apt::apticron(
$ensure_version = 'installed',
- $config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb",
+ $config = "apt/${::operatingsystem}/apticron_${::debian_codename}.erb",
$email = 'root',
$diff_only = '1',
$listchanges_profile = 'apticron',
diff --git a/manifests/dist_upgrade.pp b/manifests/dist_upgrade.pp
index bf78dcc..19c031e 100644
--- a/manifests/dist_upgrade.pp
+++ b/manifests/dist_upgrade.pp
@@ -1,18 +1,9 @@
class apt::dist_upgrade {
- if $apt::disable_update == false {
- include apt::update
- }
-
- $req = $apt::disable_update ? {
- true => undef,
- default => Exec['apt_updated'],
- }
-
exec { 'apt_dist-upgrade':
command => '/usr/bin/apt-get -q -y -o \'DPkg::Options::=--force-confold\' dist-upgrade',
refreshonly => true,
- require => $req
+ before => Exec['apt_updated']
}
}
diff --git a/manifests/dot_d_directories.pp b/manifests/dot_d_directories.pp
index 37c3fc8..0ace863 100644
--- a/manifests/dot_d_directories.pp
+++ b/manifests/dot_d_directories.pp
@@ -5,18 +5,11 @@ class apt::dot_d_directories {
'/etc/apt/apt.conf.d':
ensure => directory,
checksum => mtime,
- notify => Exec['refresh_apt'];
+ notify => Exec['apt_updated'];
'/etc/apt/sources.list.d':
ensure => directory,
checksum => mtime,
- notify => Exec['refresh_apt'];
- }
-
- exec {
- # "&& sleep 1" is workaround for older(?) clients
- 'refresh_apt':
- command => '/usr/bin/apt-get update && sleep 1',
- refreshonly => true,
+ notify => Exec['apt_updated'];
}
}
diff --git a/manifests/dselect.pp b/manifests/dselect.pp
index 6feeb9f..2b99a43 100644
--- a/manifests/dselect.pp
+++ b/manifests/dselect.pp
@@ -1,9 +1,10 @@
+# manage dselect, like
+# suppressing the annoying help texts
class apt::dselect {
- # suppress annoying help texts of dselect
- line { 'dselect_expert':
- file => '/etc/dpkg/dselect.cfg',
- line => 'expert',
+ file_line { 'dselect_expert':
+ path => '/etc/dpkg/dselect.cfg',
+ line => 'expert',
}
package { 'dselect': ensure => installed }
diff --git a/manifests/init.pp b/manifests/init.pp
index 33eac37..4c44af2 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,18 +4,20 @@
# See LICENSE for the full license granted to you.
class apt(
- $codename = $apt::params::codename,
+ $use_lts = $apt::params::use_lts,
$use_volatile = $apt::params::use_volatile,
+ $use_backports = $apt::params::use_backports,
$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,
+ $lts_url = $apt::params::lts_url,
$volatile_url = $apt::params::volatile_url,
$ubuntu_url = $apt::params::ubuntu_url,
$repos = $apt::params::repos,
$custom_preferences = $apt::params::custom_preferences,
- $disable_update = $apt::params::disable_update,
+ $custom_sources_list = '',
$custom_key_dir = $apt::params::custom_key_dir
) inherits apt::params {
case $::operatingsystem {
@@ -38,32 +40,16 @@ class apt(
require => undef,
}
- include lsb
-
- # init $release, $next_release, $next_codename, $release_version
- case $codename {
- 'n/a': {
- fail("Unknown lsbdistcodename reported by facter: '$::lsbdistcodename', please fix this by setting this variable in your manifest.")
- }
- default: {
- $release = debian_release($codename)
- }
- }
- $release_version = debian_release_version($codename)
- $next_codename = debian_nextcodename($codename)
- $next_release = debian_nextrelease($release)
-
- $sources_content = $::custom_sources_list ? {
+ $sources_content = $custom_sources_list ? {
'' => template( "apt/${::operatingsystem}/sources.list.erb"),
- default => $::custom_sources_list
+ default => $custom_sources_list
}
file {
- # include main, security and backports
+ # include main and security
# additional sources should be included via the apt::sources_list define
'/etc/apt/sources.list':
content => $sources_content,
- require => Package['lsb'],
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
owner => root,
group => 0,
mode => '0644';
@@ -110,9 +96,22 @@ class apt(
# backports uses the normal archive key now
package { 'debian-backports-keyring': ensure => absent }
+ 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 {
+ apt::sources_list {
+ 'backports-src':
+ content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}",
+ }
+ }
+ }
+
include common::moduledir
+ common::module_dir { 'apt': }
$apt_base_dir = "${common::moduledir::module_dir_path}/apt"
- modules_dir { 'apt': }
if $custom_key_dir {
file { "${apt_base_dir}/keys.d":
@@ -123,21 +122,29 @@ class apt(
mode => '0755',
}
exec { 'custom_keys':
- command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\; && /usr/bin/apt-get update",
+ command => "find ${apt_base_dir}/keys.d -type f -exec apt-key add '{}' \\;",
subscribe => File["${apt_base_dir}/keys.d"],
refreshonly => true,
+ notify => Exec[refresh_apt]
}
if $custom_preferences != false {
Exec['custom_keys'] {
- before => [ Exec[refresh_apt], File['apt_config'] ]
- }
- } else {
- Exec['custom_keys'] {
- before => Exec[refresh_apt]
+ before => File['apt_config']
}
}
}
# workaround for preseeded_package component
file { [ '/var/cache', '/var/cache/local', '/var/cache/local/preseeding' ]: ensure => directory }
+
+ exec { 'update_apt':
+ command => '/usr/bin/apt-get update',
+ require => [
+ File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ],
+ File['/etc/apt/sources.list'] ],
+ refreshonly => true,
+ # Another Semaphor for all packages to reference
+ alias => [ 'apt_updated', 'refresh_apt']
+ }
+
}
diff --git a/manifests/key.pp b/manifests/key.pp
new file mode 100644
index 0000000..cb70ec6
--- /dev/null
+++ b/manifests/key.pp
@@ -0,0 +1,13 @@
+define apt::key ($source, $ensure = 'present') {
+ validate_re(
+ $name, '\.gpg$',
+ 'An apt::key resource name must have the .gpg extension',
+ )
+
+ file {
+ "/etc/apt/trusted.gpg.d/${name}":
+ ensure => $ensure,
+ source => $source,
+ notify => Exec['apt_updated'],
+ }
+}
diff --git a/manifests/key/plain.pp b/manifests/key/plain.pp
new file mode 100644
index 0000000..dff8b51
--- /dev/null
+++ b/manifests/key/plain.pp
@@ -0,0 +1,13 @@
+define apt::key::plain ($source) {
+ file {
+ "${apt::apt_base_dir}/keys/${name}":
+ source => $source;
+ "${apt::apt_base_dir}/keys":
+ ensure => directory;
+ }
+ exec { "apt-key add '${apt::apt_base_dir}/keys/${name}'":
+ subscribe => File["${apt::apt_base_dir}/keys/${name}"],
+ refreshonly => true,
+ notify => Exec['apt_updated'],
+ }
+}
diff --git a/manifests/listchanges.pp b/manifests/listchanges.pp
index 0c163ae..e64bb1b 100644
--- a/manifests/listchanges.pp
+++ b/manifests/listchanges.pp
@@ -1,6 +1,6 @@
class apt::listchanges(
$ensure_version = 'installed',
- $config = "apt/${::operatingsystem}/listchanges_${::lsbdistcodename}.erb",
+ $config = "apt/${::operatingsystem}/listchanges_${::debian_codename}.erb",
$frontend = 'mail',
$email = 'root',
$confirm = '0',
diff --git a/manifests/params.pp b/manifests/params.pp
index 12273ac..28af06e 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,18 +1,22 @@
class apt::params () {
- $codename = $::lsbdistcodename
+ $use_lts = false
$use_volatile = false
+ $use_backports = true
$include_src = false
$use_next_release = false
- $debian_url = 'http://http.debian.net/debian/'
+ $debian_url = 'http://httpredir.debian.org/debian/'
$security_url = 'http://security.debian.org/'
- $backports_url = $::lsbdistcodename ? {
- 'wheezy' => $debian_url,
- default => 'http://backports.debian.org/debian-backports/',
+ $ubuntu_url = 'http://archive.ubuntu.com/ubuntu'
+ $backports_url = $::debian_codename ? {
+ 'squeeze' => 'http://backports.debian.org/debian-backports/',
+ default => $::operatingsystem ? {
+ 'Ubuntu' => $ubuntu_url,
+ default => $debian_url,
+ }
}
+ $lts_url = $debian_url
$volatile_url = 'http://volatile.debian.org/debian-volatile/'
- $ubuntu_url = 'http://archive.ubuntu.com/ubuntu'
$repos = 'auto'
$custom_preferences = ''
- $disable_update = false
$custom_key_dir = false
}
diff --git a/manifests/preferences.pp b/manifests/preferences.pp
index 9ed24c1..6982ca0 100644
--- a/manifests/preferences.pp
+++ b/manifests/preferences.pp
@@ -2,8 +2,8 @@ class apt::preferences {
$pref_contents = $apt::custom_preferences ? {
'' => $::operatingsystem ? {
- 'debian' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"),
- 'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"),
+ 'debian' => template("apt/${::operatingsystem}/preferences_${::debian_codename}.erb"),
+ 'ubuntu' => template("apt/${::operatingsystem}/preferences_${::ubuntu_codename}.erb"),
},
default => $apt::custom_preferences
}
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp
index 5ae748b..b7dba0d 100644
--- a/manifests/preferences_snippet.pp
+++ b/manifests/preferences_snippet.pp
@@ -13,7 +13,7 @@ define apt::preferences_snippet (
}
if $ensure == 'present' {
- if $custom_preferences == false {
+ if $apt::custom_preferences == false {
fail('Trying to define a preferences_snippet with $custom_preferences set to false.')
}
@@ -31,12 +31,10 @@ define apt::preferences_snippet (
file { "/etc/apt/preferences.d/${name}":
ensure => $ensure,
- owner => root, group => 0, mode => '0644';
+ owner => root, group => 0, mode => '0644',
+ before => Exec['apt_updated'];
}
- # This should really work in the same manner as sources_list and apt_conf
- # snippets, but since the preferences.d directory cannot be used in Debian
- # lenny, we can't generalize without going into ugly special-casing.
case $source {
'': {
case $release {
diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp
index 9bca8b1..3ef0687 100644
--- a/manifests/preseeded_package.pp
+++ b/manifests/preseeded_package.pp
@@ -4,7 +4,7 @@ define apt::preseeded_package (
) {
$seedfile = "/var/cache/local/preseeding/${name}.seeds"
$real_content = $content ? {
- '' => template ( "site_apt/${::lsbdistcodename}/${name}.seeds" ),
+ '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ),
default => $content
}
diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp
index 3367f83..0ee068d 100644
--- a/manifests/sources_list.pp
+++ b/manifests/sources_list.pp
@@ -15,22 +15,24 @@ define apt::sources_list (
include apt::dot_d_directories
+ $realname = regsubst($name, '\.list$', '')
+
# One would expect the 'file' resource on sources.list.d to trigger an
# apt-get update when files are added or modified in the directory, but it
# apparently doesn't.
- file { "/etc/apt/sources.list.d/${name}":
+ file { "/etc/apt/sources.list.d/${realname}.list":
ensure => $ensure,
owner => root, group => 0, mode => '0644',
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
}
if $source {
- File["/etc/apt/sources.list.d/${name}"] {
+ File["/etc/apt/sources.list.d/${realname}.list"] {
source => $source,
}
}
else {
- File["/etc/apt/sources.list.d/${name}"] {
+ File["/etc/apt/sources.list.d/${realname}.list"] {
content => $content,
}
}
diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp
index 398a1a7..52d7542 100644
--- a/manifests/unattended_upgrades.pp
+++ b/manifests/unattended_upgrades.pp
@@ -1,33 +1,34 @@
-class apt::unattended_upgrades {
+class apt::unattended_upgrades (
+ $config_content = undef,
+ $config_template = 'apt/50unattended-upgrades.erb',
+ $mailonlyonerror = true,
+ $mail_recipient = 'root',
+ $blacklisted_packages = [],
+ $ensure_version = present
+) {
package { 'unattended-upgrades':
- ensure => present,
- require => undef
+ ensure => $ensure_version
}
- apt_conf { '50unattended-upgrades':
- source => [
- "puppet:///modules/site_apt/${::lsbdistid}/50unattended-upgrades.${::lsbdistcodename}",
- "puppet:///modules/site_apt/${::lsbdistid}/50unattended-upgrades",
- "puppet:///modules/apt/${::lsbdistid}/50unattended-upgrades.${::lsbdistcodename}",
- "puppet:///modules/apt/${::lsbdistid}/50unattended-upgrades" ],
+ # For some reason, this directory is sometimes absent, which causes
+ # unattended-upgrades to crash.
+ file { '/var/log/unattended-upgrades':
+ ensure => directory,
+ owner => 'root',
+ group => 0,
+ mode => '0755',
require => Package['unattended-upgrades'],
}
- if defined(File['apt_config']) {
- Apt_conf['50unattended-upgrades'] {
- before => File['apt_config'],
- }
+ $file_content = $config_content ? {
+ undef => template($config_template),
+ default => $config_content
}
- if $operatingsystem == 'ubuntu' {
- file { '/etc/apt/apt.conf.d/10periodic':
- ensure => present,
- owner => root,
- group => root,
- mode => 0644,
- source => 'puppet:///modules/apt/10periodic',
- require => Package['unattended-upgrades'],
- }
+ apt_conf { '50unattended-upgrades':
+ content => $file_content,
+ require => Package['unattended-upgrades'],
+ refresh_apt => false
}
}
diff --git a/manifests/update.pp b/manifests/update.pp
index 3f45125..dde8320 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -1,13 +1,7 @@
-class apt::update {
+class apt::update inherits ::apt {
- exec { 'update_apt':
- command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
- require => [
- File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ],
- File['/etc/apt/sources.list'] ],
- loglevel => info,
- # Another Semaphor for all packages to reference
- alias => 'apt_updated'
+ Exec['update_apt'] {
+ refreshonly => false
}
}
diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp
index d607150..30572c9 100644
--- a/manifests/upgrade_package.pp
+++ b/manifests/upgrade_package.pp
@@ -2,10 +2,6 @@ define apt::upgrade_package (
$version = ''
) {
- if $apt::disable_update == false {
- include apt::update
- }
-
$version_suffix = $version ? {
'' => '',
'latest' => '',
@@ -26,17 +22,10 @@ define apt::upgrade_package (
}
}
- $req = $apt::disable_update ? {
- true => Package['apt-show-versions', 'dctrl-tools'],
- default => [
- Exec['apt_updated'],
- Package['apt-show-versions', 'dctrl-tools']
- ],
- }
-
exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}":
onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
- require => $req
+ require => Package['apt-show-versions', 'dctrl-tools'],
+ before => Exec['apt_updated']
}
}