Skip to content

Commit

Permalink
2.8: Move update_cache to after self.yum_baseurl definition (#56613) (#…
Browse files Browse the repository at this point in the history
…56705)

* Move update_cache to after self.yum_baseurl definition (#56613)


(cherry picked from commit e135661)

* Add changelog
  • Loading branch information
mkrizek authored and abadger committed May 22, 2019
1 parent 171ef3e commit f0e5f2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/56638-yum-update_cache-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- yum - fix failure when using ``update_cache`` standalone (https://github.com/ansible/ansible/issues/56638)
22 changes: 11 additions & 11 deletions lib/ansible/modules/packaging/os/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,17 @@ def run(self):
if error_msgs:
self.module.fail_json(msg='. '.join(error_msgs))

# fedora will redirect yum to dnf, which has incompatibilities
# with how this module expects yum to operate. If yum-deprecated
# is available, use that instead to emulate the old behaviors.
if self.module.get_bin_path('yum-deprecated'):
yumbin = self.module.get_bin_path('yum-deprecated')
else:
yumbin = self.module.get_bin_path('yum')

# need debug level 2 to get 'Nothing to do' for groupinstall.
self.yum_basecmd = [yumbin, '-d', '2', '-y']

if self.update_cache and not self.names and not self.list:
rc, stdout, stderr = self.module.run_command(self.yum_basecmd + ['clean', 'expire-cache'])
if rc == 0:
Expand All @@ -1511,17 +1522,6 @@ def run(self):
results=[stderr],
)

# fedora will redirect yum to dnf, which has incompatibilities
# with how this module expects yum to operate. If yum-deprecated
# is available, use that instead to emulate the old behaviors.
if self.module.get_bin_path('yum-deprecated'):
yumbin = self.module.get_bin_path('yum-deprecated')
else:
yumbin = self.module.get_bin_path('yum')

# need debug level 2 to get 'Nothing to do' for groupinstall.
self.yum_basecmd = [yumbin, '-d', '2', '-y']

repoquerybin = self.module.get_bin_path('repoquery', required=False)

if self.install_repoquery and not repoquerybin and not self.module.check_mode:
Expand Down

0 comments on commit f0e5f2c

Please sign in to comment.