From 91a49f53c49a6edcad6ceb5152c069cc998a263d Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Mon, 29 Sep 2008 14:36:28 -0400 Subject: add the upgrade_package define This simplifies upgrades for DSA security announcements or point-releases. This will ensure that the named package is upgrade to the version specified, only if the package is installed, otherwise nothing happens. If the specified version is 'latest' (the default), then the package is ensured to be upgraded to the latest package revision when it becomes available. For example, the following upgrades the perl package to version 5.8.8-7etch1 (if it is installed), it also upgrades the syslog-ng and perl-modules packages to their latest (also, only if they are installed): upgrade_package { "perl": version => '5.8.8-7etch1'; "syslog-ng": version => latest; "perl-modules": } --- manifests/init.pp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 77d5a7f..85911bc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -181,6 +181,26 @@ class apt { require => File[$seedfile], } } + + define upgrade_package ($version = "") { + case $version { + '': { + exec { "aptitude -y install $name": + onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ], + } + } + 'latest': { + exec { "aptitude -y install $name": + onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ], + } + } + default: { + exec { "aptitude -y install $name=$version": + onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ], + } + } + } + } } class dselect { -- cgit v1.2.3