From f9043bf1565a5a2dda65839c4187a9b29ae6e14b Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Tue, 27 Mar 2012 12:06:21 -0400 Subject: [PATCH 1/3] make yum module work with older yum for rhel5 :( --- library/yum | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/yum b/library/yum index 5ef8b7818cf..a3b95d14ac8 100755 --- a/library/yum +++ b/library/yum @@ -41,7 +41,12 @@ def yum_base(conf_file=None, cachedir=False): if conf_file and os.path.exists(conf_file): my.preconf.fn = conf_file if cachedir: - my.setCacheDir() + if hasattr(my, 'setCacheDir'): + my.setCacheDir() + else: + cachedir = yum.misc.getCacheDir() + my.repos.setCacheDir(cachedir) + my.conf.cache = 0 return my From 2fe193034cdf96adee4235c0e7500cfcd51b7b2f Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Tue, 27 Mar 2012 13:58:49 -0400 Subject: [PATCH 2/3] fix up latest so it behaves like latest should if installed and updated available: apply update if not installed and available: install --- library/yum | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/yum b/library/yum index a3b95d14ac8..cf9a697edd1 100755 --- a/library/yum +++ b/library/yum @@ -214,13 +214,17 @@ def ensure(my, state, pkgspec): return res if state == 'latest': - if not [ pkg_to_dict(po) for - po in my.doPackageLists(pkgnarrow='updates', patterns=[pkgspec]).updates ]: + updates = my.doPackageLists(pkgnarrow='updates', patterns=[pkgspec]).updates + avail = my.doPackageLists(pkgnarrow='available', patterns=[pkgspec]).available + if not updates and not avail: # there nothing in updates matching this. return { 'changed':False,} - # we have something in updates - cmd = "yum -c %s -d1 -y update '%s'" % (yumconf, pkgspec) + # we have something in updates or available + if not updates: + cmd = "yum -c %s -d1 -y install '%s'" % (yumconf, pkgspec) + else: + cmd = "yum -c %s -d1 -y update '%s'" % (yumconf, pkgspec) rc, out, err = run_yum(cmd) # FIXME if it is - update it and check to see if it applied # check to see if there is no longer an update available for the pkgspec From fc02992bcdd4ae672e0d08343d865f7371c800dc Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Tue, 27 Mar 2012 14:15:48 -0400 Subject: [PATCH 3/3] make sure latest outputs an error if the thing you've listed as 'latest' is not there at all or even updateable --- library/yum | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/yum b/library/yum index cf9a697edd1..524b3a0ebd0 100755 --- a/library/yum +++ b/library/yum @@ -217,7 +217,9 @@ def ensure(my, state, pkgspec): updates = my.doPackageLists(pkgnarrow='updates', patterns=[pkgspec]).updates avail = my.doPackageLists(pkgnarrow='available', patterns=[pkgspec]).available if not updates and not avail: - # there nothing in updates matching this. + if not my.doPackageLists(pkgnarrow='installed', patterns=[pkgspec]).installed: + msg = "No Package matching '%s' found available, installed or updated" % pkgspec + return { 'changed':False, 'failed':True, 'msg': msg } return { 'changed':False,} # we have something in updates or available @@ -226,6 +228,7 @@ def ensure(my, state, pkgspec): else: cmd = "yum -c %s -d1 -y update '%s'" % (yumconf, pkgspec) rc, out, err = run_yum(cmd) + # FIXME if it is - update it and check to see if it applied # check to see if there is no longer an update available for the pkgspec if rc: