aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-12-15 09:47:57 +0100
committerintrigeri <intrigeri@boum.org>2010-12-15 09:47:57 +0100
commitaf8ecf1e9f6745a2c2d8c09b0f1e1d7c572981b9 (patch)
tree22b48aa33ff5386e7f31c4f3dec7101ea9b6e41b /manifests
parent4979889584b2b150e43f9930f5eccbf6cf5245fa (diff)
downloadpuppet-apt-af8ecf1e9f6745a2c2d8c09b0f1e1d7c572981b9.tar.gz
puppet-apt-af8ecf1e9f6745a2c2d8c09b0f1e1d7c572981b9.tar.bz2
Repair Exec['update_apt'] to run apt-get update when needed.
Move this Exec to a dedicated class that is not included by default i.e. we default not to "apt-get update" on every Puppet run. We now make use of this class in the apt::upgrade_package define to make sure APT indexes are up-to-date before attempting package upgrades. One may now use the following to ensure current packages are installed by Package resources: include apt::update Package { require => Exec[apt_updated] }
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp9
-rw-r--r--manifests/update.pp12
-rw-r--r--manifests/upgrade_package.pp23
3 files changed, 24 insertions, 20 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 8a4a0a5..b5be91f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -142,15 +142,6 @@ class apt {
command => '/usr/bin/apt-get update && sleep 1',
refreshonly => true,
subscribe => [ File['/etc/apt/apt.conf.d'], Config_file['/etc/apt/sources.list'] ];
-
- 'update_apt':
- command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
- refreshonly => true,
- require => [ File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ],
- Config_file['/etc/apt/sources.list'] ],
- loglevel => info,
- # Another Semaphor for all packages to reference
- alias => "apt_updated";
}
## This package should really always be current
diff --git a/manifests/update.pp b/manifests/update.pp
new file mode 100644
index 0000000..ae992f4
--- /dev/null
+++ b/manifests/update.pp
@@ -0,0 +1,12 @@
+class apt::update {
+
+ exec { 'update_apt':
+ command => '/usr/bin/apt-get update && /usr/bin/apt-get autoclean',
+ require => [ File['/etc/apt/apt.conf.d', '/etc/apt/preferences' ],
+ Config_file['/etc/apt/sources.list'] ],
+ loglevel => info,
+ # Another Semaphor for all packages to reference
+ alias => "apt_updated"
+ }
+
+}
diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp
index 7656a9b..9f280c6 100644
--- a/manifests/upgrade_package.pp
+++ b/manifests/upgrade_package.pp
@@ -1,15 +1,16 @@
define apt::upgrade_package ($version = "") {
- case $version {
- '', 'latest': {
- exec { "/usr/bin/apt-get update && aptitude -y install $name":
- onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
- }
- }
- default: {
- exec { "/usr/bin/apt-get update && aptitude -y install $name=$version":
- onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
- }
- }
+ include apt::update
+
+ $version_suffix = $version ? {
+ '' => '',
+ 'latest' => '',
+ default => "=${version}",
+ }
+
+ exec { "aptitude -y install ${name}${version_suffix}":
+ onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ],
+ require => Exec['apt_updated'],
}
+
}