Return change results in a dictionary listing the package names.

Fix a parsing problem when package names contain a dot.
This commit is contained in:
Toshio Kuratomi 2015-08-20 13:02:29 -07:00
parent e5e0a70fc1
commit 9d4694122d

View file

@ -609,10 +609,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
except Exception, e: except Exception, e:
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e)) module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
for p in pkgs: module.exit_json(changed=True, results=res['results'], changes=dict(installed=pkgs))
# take note of which packages are getting installed
res['results'].append('%s will be installed' % p)
module.exit_json(changed=True, results=res['results'])
changed = True changed = True
@ -680,10 +677,7 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
cmd = yum_basecmd + ["remove"] + pkgs cmd = yum_basecmd + ["remove"] + pkgs
if module.check_mode: if module.check_mode:
# take note of which packages are getting removed module.exit_json(changed=True, results=res['results'], changes=dict(removed=pkgs))
for p in pkgs:
res['results'].append('%s will be removed' % p)
module.exit_json(changed=True, results=res['results'])
rc, out, err = module.run_command(cmd) rc, out, err = module.run_command(cmd)
@ -745,7 +739,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
continue continue
else: else:
pkg, version, repo = line pkg, version, repo = line
name, dist = pkg.split('.') name, dist = pkg.rsplit('.', 1)
updates.update({name: {'version': version, 'dist': dist, 'repo': repo}}) updates.update({name: {'version': version, 'dist': dist, 'repo': repo}})
elif rc == 1: elif rc == 1:
res['msg'] = err res['msg'] = err
@ -800,15 +794,15 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
# check_mode output # check_mode output
if module.check_mode: if module.check_mode:
to_update = []
for w in will_update: for w in will_update:
if w.startswith('@'): if w.startswith('@'):
to_update.append((w, None))
msg = '%s will be updated' % w msg = '%s will be updated' % w
else: else:
msg = '%s will be updated with %s-%s.%s from %s' % (w, w, updates[w]['version'], updates[w]['dist'], updates[w]['repo']) to_update.append((w, '%s.%s from %s' % (updates[w]['version'], updates[w]['dist'], updates[w]['repo'])))
res['results'].append(msg)
for p in pkgs['install']: res['changes'] = dict(installed=pkgs['install'], updated=to_update)
res['results'].append('%s will be installed' % p)
if len(will_update) > 0 or len(pkgs['install']) > 0: if len(will_update) > 0 or len(pkgs['install']) > 0:
res['changed'] = True res['changed'] = True