Fix yum with rpm file or url when state=latest (#27775)

(cherry picked from commit fa6ce54011)
This commit is contained in:
Nicolas Porcel 2017-08-07 10:48:30 +02:00 committed by Toshio Kuratomi
parent 278d450329
commit d36a651588

View file

@ -952,6 +952,35 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, in
pkgs['update'].append(spec)
will_update.add(spec)
continue
# check if pkgspec is installed (if possible for idempotence)
# localpkg
elif spec.endswith('.rpm') and '://' not in spec:
if not os.path.exists(spec):
res['msg'] += "No RPM file matching '%s' found on system" % spec
res['results'].append("No RPM file matching '%s' found on system" % spec)
res['rc'] = 127 # Ensure the task fails in with-loop
module.fail_json(**res)
# get the pkg name-v-r.arch
nvra = local_nvra(module, spec)
# local rpm files can't be updated
if not is_installed(module, repoq, nvra, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot):
pkgs['install'].append(spec)
continue
# URL
elif '://' in spec:
# download package so that we can check if it's already installed
package = fetch_rpm_from_url(spec, module=module)
nvra = local_nvra(module, package)
# local rpm files can't be updated
if not is_installed(module, repoq, nvra, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot):
pkgs['install'].append(package)
continue
# dep/pkgname - find it
else:
if is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot):