From d1fa210bedf5314fbdc83bd9f63d1d1cd68c6009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Tue, 15 Aug 2017 16:20:10 +0200 Subject: [PATCH] yum: using install to update specified packages (#26266) * yum: using install for update packages * yum: fix return changed when latest version installed * yum: fix changed when nothing to do --- lib/ansible/modules/packaging/os/yum.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 6271e333dfe..d0336599062 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -1093,15 +1093,19 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, in if len(pkgs['install']) > 0: # install missing cmd = yum_basecmd + ['install'] + pkgs['install'] rc, out, err = module.run_command(cmd) - if not out.strip().lower().endswith("no packages marked for update"): + out_lower = out.strip().lower() + if not out_lower.endswith("no packages marked for update") and \ + not out_lower.endswith("nothing to do"): res['changed'] = True else: rc, out, err = [0, '', ''] if len(will_update) > 0: # update present - cmd = yum_basecmd + ['update'] + pkgs['update'] + cmd = yum_basecmd + ['install'] + pkgs['update'] rc2, out2, err2 = module.run_command(cmd) - if not out2.strip().lower().endswith("no packages marked for update"): + out2_lower = out2.strip().lower() + if not out2_lower.endswith("no packages marked for update") and \ + not out2_lower.endswith("nothing to do"): res['changed'] = True else: rc2, out2, err2 = [0, '', '']