summaryrefslogtreecommitdiff
path: root/lib/ansible/modules
diff options
context:
space:
mode:
authorOrion Poplawski <orion@nwra.com>2018-07-18 13:11:32 -0600
committeransibot <ansibot@users.noreply.github.com>2018-07-18 15:11:32 -0400
commit32436ea9a529841c1f8196dcd28e752c1888f5aa (patch)
tree0f0b22d7936fd7c73c25f6eb100482d6832a967b /lib/ansible/modules
parent67cf2da2a1a0007915cc99c77c72616e6c29d478 (diff)
downloadansible-32436ea9a529841c1f8196dcd28e752c1888f5aa.tar.gz
dnf: Call dnf.Base.close() before exit to cleanup. (#41810)
Diffstat (limited to 'lib/ansible/modules')
-rw-r--r--lib/ansible/modules/packaging/os/dnf.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py
index bdcbdee3e6..ce023fe892 100644
--- a/lib/ansible/modules/packaging/os/dnf.py
+++ b/lib/ansible/modules/packaging/os/dnf.py
@@ -287,6 +287,7 @@ def list_items(module, base, command):
packages = dnf.subject.Subject(command).get_best_query(base.sack)
results = [_package_dict(package) for package in packages]
+ base.close()
module.exit_json(results=results)
@@ -295,6 +296,7 @@ def _mark_package_install(module, base, pkg_spec):
try:
base.install(pkg_spec)
except dnf.exceptions.MarkingError:
+ base.close()
module.fail_json(msg="No package {0} available.".format(pkg_spec))
@@ -353,6 +355,7 @@ def ensure(module, base, state, names, autoremove):
if environment:
environments.append(environment.id)
else:
+ base.close()
module.fail_json(
msg="No group {0} available.".format(group_spec))
@@ -419,6 +422,7 @@ def ensure(module, base, state, names, autoremove):
base.conf.clean_requirements_on_remove = autoremove
if filenames:
+ base.close()
module.fail_json(
msg="Cannot remove paths -- please specify package name.")
@@ -450,16 +454,20 @@ def ensure(module, base, state, names, autoremove):
if not base.resolve(allow_erasing=allow_erasing):
if failures:
+ base.close()
module.fail_json(msg='Failed to install some of the '
'specified packages',
failures=failures)
+ base.close()
module.exit_json(msg="Nothing to do")
else:
if module.check_mode:
if failures:
+ base.close()
module.fail_json(msg='Failed to install some of the '
'specified packages',
failures=failures)
+ base.close()
module.exit_json(changed=True)
base.download_packages(base.transaction.install_set)
@@ -471,9 +479,11 @@ def ensure(module, base, state, names, autoremove):
response['results'].append("Removed: {0}".format(package))
if failures:
+ base.close()
module.fail_json(msg='Failed to install some of the '
'specified packages',
failures=failures)
+ base.close()
module.exit_json(**response)