Skip to content

Commit

Permalink
Move update_cache to after self.yum_baseurl definition (#56613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeophlite authored and mkrizek committed May 21, 2019
1 parent a4144e1 commit e135661
Showing 1 changed file with 11 additions and 11 deletions.
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 @@ -1509,6 +1509,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 @@ -1526,17 +1537,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 e135661

Please sign in to comment.