Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yum module with rpm file or url #27775

Merged
merged 1 commit into from
Aug 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/ansible/modules/packaging/os/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,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):
Expand Down