mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #1487 from skvidal/devel
fix up remove and fix fixme checking to see if pkg was removed
This commit is contained in:
commit
91cf257e9c
1 changed files with 31 additions and 27 deletions
56
library/yum
56
library/yum
|
@ -429,43 +429,47 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
res['msg'] = ''
|
res['msg'] = ''
|
||||||
res['changed'] = False
|
res['changed'] = False
|
||||||
res['rc'] = 0
|
res['rc'] = 0
|
||||||
|
res['failed'] = False
|
||||||
|
|
||||||
for spec in items:
|
for pkg in items:
|
||||||
pkg = None
|
is_group = False
|
||||||
|
# group remove - this is doom on a stick
|
||||||
# group remove - hope you like things dying!
|
if pkg.startswith('@'):
|
||||||
if spec.startswith('@'):
|
is_group = True
|
||||||
pkg = spec
|
|
||||||
# req or pkgname remove
|
|
||||||
else:
|
else:
|
||||||
pkglist = is_installed(module, repoq, spec, conf_file, en_repos=en_repos, dis_repos=dis_repos)
|
if not is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
if not pkglist:
|
res['results'].append('%s is not installed' % pkg)
|
||||||
found = False
|
|
||||||
else:
|
|
||||||
found = True
|
|
||||||
|
|
||||||
if not found:
|
|
||||||
res['results'].append('%s is not installed' % spec)
|
|
||||||
continue
|
continue
|
||||||
pkg = spec
|
|
||||||
|
|
||||||
|
# run an actual yum transaction
|
||||||
cmd = yum_basecmd + ["remove", pkg]
|
cmd = yum_basecmd + ["remove", pkg]
|
||||||
rc, out, err = run(cmd)
|
rc, out, err = run(cmd)
|
||||||
|
|
||||||
# FIXME if we ran the remove - check to make sure it actually removed :(
|
# at this point we should check to see if the pkg is no longer present
|
||||||
# look for the pkg in the rpmdb - this is notoriously hard for groups :(
|
|
||||||
if rc != 0:
|
if not is_group: # we can't sensibly check for a group being uninstalled reliably
|
||||||
res['changed'] = False
|
# look to see if the pkg shows up from is_installed. If it doesn't
|
||||||
res['failed'] = True
|
if not is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos):
|
||||||
res['rc'] = rc
|
|
||||||
res['results'].append(out)
|
|
||||||
res['msg'] += err
|
|
||||||
else:
|
|
||||||
res['changed'] = True
|
res['changed'] = True
|
||||||
res['rc'] = 0
|
else:
|
||||||
|
res['failed'] = True
|
||||||
|
|
||||||
|
if rc != 0:
|
||||||
|
res['failed'] = True
|
||||||
|
|
||||||
|
# compile the results into one batch. If anything is changed
|
||||||
|
# then mark changed
|
||||||
|
# at the end - if we've end up failed then fail out of the rest
|
||||||
|
# of the process
|
||||||
|
res['changed'] = res['changed'] or False
|
||||||
|
res['failed'] = res['failed'] or False
|
||||||
|
res['rc'] += rc
|
||||||
res['results'].append(out)
|
res['results'].append(out)
|
||||||
res['msg'] += err
|
res['msg'] += err
|
||||||
|
|
||||||
|
if res['failed']:
|
||||||
|
module.fail_json(**res)
|
||||||
|
|
||||||
module.exit_json(**res)
|
module.exit_json(**res)
|
||||||
|
|
||||||
def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
||||||
|
|
Loading…
Reference in a new issue