summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2016-01-26 14:42:17 +0100
committervarac <varacanero@zeromail.org>2016-02-01 20:49:14 +0100
commit474c5f8e9a88ad1edf3b00c90356c88a6c92c18a (patch)
treea15775fa23fda48039a18c5c59f45266880220b4
parentd459567bf246eee85cd101c2e2f17f451e6230b8 (diff)
[refactor] Unify `apt-get update` into one resource
Before, there were two Execs that did an `apt-get update`, `Exec[refresh_apt]` and `Exec[apt_updated]`, which were triggered by different resources. This changes gets rid of the first one, and all resources now depend on `Exec[apt_updated]`.
-rw-r--r--README46
-rw-r--r--manifests/apt_conf.pp2
-rw-r--r--manifests/dist_upgrade.pp11
-rw-r--r--manifests/dot_d_directories.pp11
-rw-r--r--manifests/init.pp14
-rw-r--r--manifests/key.pp2
-rw-r--r--manifests/key/plain.pp2
-rw-r--r--manifests/preferences_snippet.pp2
-rw-r--r--manifests/sources_list.pp2
-rw-r--r--manifests/update.pp12
10 files changed, 53 insertions, 51 deletions
diff --git a/README b/README
index be3a159..e443fae 100644
--- a/README
+++ b/README
@@ -17,6 +17,14 @@ Ubuntu support is lagging behind but not absent either.
! Upgrade Notice !
+ * The `disable_update` parameter has been removed. The main apt class
+ defaults to *not* run an `apt-get update` on every run anyway so this
+ parameter seems useless.
+ You can include the `apt::update` class if you want it to be run every time.
+
+ * The `apt::upgrade_package` now doesn't automatically call an Exec['apt_updated']
+ anymore, so you would need to include `apt::update` now by hand.
+
* The apt::codename parameter has been removed. In its place, the
debian_codename fact may be overridden via an environment variable. This
will affect all other debian_* facts, and achieve the same result.
@@ -139,6 +147,14 @@ Example usage:
Class parameters:
+* use_lts
+
+ If this variable is set to true the CODENAME-lts sources (such as
+ squeeze-lts) are added.
+
+ By default this is false for backward compatibility with older
+ versions of this module.
+
* use_volatile
If this variable is set to true the CODENAME-updates sources (such as
@@ -180,14 +196,6 @@ Class parameters:
If this variable is set the default repositories list ("main contrib non-free")
is overriden.
-* disable_update
-
- Disable "apt-get update" which is normally triggered by apt::upgrade_package
- and apt::dist_upgrade.
-
- Note that nodes can be updated once a day by using
- APT::Periodic::Update-Package-Lists "1";
- in i.e. /etc/apt/apt.conf.d/80_apt_update_daily.
* custom_preferences
@@ -336,7 +344,7 @@ the following parameterized variables, which can be changed:
Example usage:
class { 'apt::listchanges': email => 'foo@example.com' }
-
+
apt::proxy_client
-----------------
@@ -451,7 +459,7 @@ following in your manifest:
apt::preseeded_package { locales: }
-You can also specify the content of the seed via the content parameter,
+You can also specify the content of the seed via the content parameter,
for example:
apt::preseeded_package { 'apticron':
@@ -547,18 +555,22 @@ Exec['apt_updated']
-------------------
After this point the APT indexes are up-to-date.
+This resource is set to `refreshonly => true` so it is not run on
+every puppetrun. To run this every time, you can include the `apt::update`
+class.
This resource is usually used like this to ensure current packages are
installed by Package resources:
- include apt::update
- Package { require => Exec['apt_updated'] }
+ include apt::update
+ Package { require => Exec['apt_updated'] }
+
+Note that nodes can be updated once a day by using
+
+ APT::Periodic::Update-Package-Lists "1";
+
+in i.e. /etc/apt/apt.conf.d/80_apt_update_daily.
-Please note that the apt::upgrade_package define automatically uses
-this resource so you don't have to manage this yourself if you need to
-make sure APT indexes are up-to-date before a package upgrade is
-attempted, but don't want "apt-get update" to happen on every Puppet
-run.
Tests
=====
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/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/init.pp b/manifests/init.pp
index 1e7ddd7..f9f9357 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -50,7 +50,7 @@ class apt(
# additional sources should be included via the apt::sources_list define
'/etc/apt/sources.list':
content => $sources_content,
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
owner => root,
group => 0,
mode => '0644';
@@ -137,4 +137,16 @@ class apt(
# 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 && /usr/bin/apt-get autoclean',
+ 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']
+ }
+
}
diff --git a/manifests/key.pp b/manifests/key.pp
index 65b62e9..cb70ec6 100644
--- a/manifests/key.pp
+++ b/manifests/key.pp
@@ -8,6 +8,6 @@ define apt::key ($source, $ensure = 'present') {
"/etc/apt/trusted.gpg.d/${name}":
ensure => $ensure,
source => $source,
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
}
}
diff --git a/manifests/key/plain.pp b/manifests/key/plain.pp
index e4a2f89..dff8b51 100644
--- a/manifests/key/plain.pp
+++ b/manifests/key/plain.pp
@@ -8,6 +8,6 @@ define apt::key::plain ($source) {
exec { "apt-key add '${apt::apt_base_dir}/keys/${name}'":
subscribe => File["${apt::apt_base_dir}/keys/${name}"],
refreshonly => true,
- notify => Exec['refresh_apt'],
+ notify => Exec['apt_updated'],
}
}
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp
index 99feac4..b7dba0d 100644
--- a/manifests/preferences_snippet.pp
+++ b/manifests/preferences_snippet.pp
@@ -32,7 +32,7 @@ define apt::preferences_snippet (
file { "/etc/apt/preferences.d/${name}":
ensure => $ensure,
owner => root, group => 0, mode => '0644',
- before => Exec['refresh_apt'];
+ before => Exec['apt_updated'];
}
case $source {
diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp
index aefad2d..0ee068d 100644
--- a/manifests/sources_list.pp
+++ b/manifests/sources_list.pp
@@ -23,7 +23,7 @@ define apt::sources_list (
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 {
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
}
}