Ensure we clean up if an exception kills strategy.run. Fixes #23958 (#71513)

pull/68151/head
Matt Martz 4 years ago committed by GitHub
parent d398a4b4f0
commit 0cf4aabc55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- Ensure if a traceback halts ``strategy.run`` that we still attempt to clean up
(https://github.com/ansible/ansible/issues/23958)

@ -289,14 +289,16 @@ class TaskQueueManager:
self._start_at_done = True
# and run the play using the strategy and cleanup on way out
play_return = strategy.run(iterator, play_context)
try:
play_return = strategy.run(iterator, play_context)
finally:
strategy.cleanup()
self._cleanup_processes()
# now re-save the hosts that failed from the iterator to our internal list
for host_name in iterator.get_failed_hosts():
self._failed_hosts[host_name] = True
strategy.cleanup()
self._cleanup_processes()
return play_return
def cleanup(self):

Loading…
Cancel
Save