]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
add the upgrade_package define
authorMicah Anderson <micah@riseup.net>
Mon, 29 Sep 2008 18:36:28 +0000 (14:36 -0400)
committerMicah Anderson <micah@riseup.net>
Mon, 29 Sep 2008 18:36:28 +0000 (14:36 -0400)
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

index 77d5a7fbfb569000013534c631221724adcc1c3e..85911bc4ce7c69b9c4c3cf8758a6c6ff11bbdb35 100644 (file)
@@ -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 {