summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Torbett <edward@torbett.co.uk>2015-06-11 15:21:30 +0100
committerToshio Kuratomi <toshio@fedoraproject.org>2015-06-15 17:43:05 -0700
commit1ad75ce0e783e3190fcb3c0560ec94f934daa457 (patch)
tree3c7517230bbbc7a13cef139eedc20ead8197bd97
parent0d64b966ac538bcce564f42862119d04de430ce2 (diff)
downloadansible-modules-core-1ad75ce0e783e3190fcb3c0560ec94f934daa457.tar.gz
Added multi package operation to remove as suggested by @abadger. Adding to latest is a little more complex due to '*' support.
-rw-r--r--packaging/os/yum.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/packaging/os/yum.py b/packaging/os/yum.py
index 4d28b89a..a52d33be 100644
--- a/packaging/os/yum.py
+++ b/packaging/os/yum.py
@@ -636,6 +636,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
+ pkgs = []
res = {}
res['results'] = []
res['msg'] = ''
@@ -652,17 +653,20 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
res['results'].append('%s is not installed' % pkg)
continue
+ pkgs.append(pkg)
+
+ if pkgs:
# run an actual yum transaction
- cmd = yum_basecmd + ["remove", pkg]
+ cmd = yum_basecmd + ["remove"] + pkg
if module.check_mode:
module.exit_json(changed=True)
rc, out, err = module.run_command(cmd)
- res['rc'] += rc
+ res['rc'] = rc
res['results'].append(out)
- res['msg'] += err
+ res['msg'] = err
# compile the results into one batch. If anything is changed
# then mark changed
@@ -671,12 +675,13 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
# at this point we should check to see if the pkg is no longer present
- if not is_group: # we can't sensibly check for a group being uninstalled reliably
- # look to see if the pkg shows up from is_installed. If it doesn't
- if not is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos):
- res['changed'] = True
- else:
- module.fail_json(**res)
+ for pkg in pkgs:
+ if not pkg.startswith('@'): # we can't sensibly check for a group being uninstalled reliably
+ # look to see if the pkg shows up from is_installed. If it doesn't
+ if not is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos):
+ res['changed'] = True
+ else:
+ module.fail_json(**res)
if rc != 0:
module.fail_json(**res)