1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix up latest so it behaves like latest should

if installed and updated available: apply update
if not installed and available: install
This commit is contained in:
Seth Vidal 2012-03-27 13:58:49 -04:00
parent f9043bf156
commit 2fe193034c

View file

@ -214,12 +214,16 @@ 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
# 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