diff options
author | Matt Martz <matt@sivel.net> | 2019-12-06 16:29:26 -0600 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2020-01-10 18:29:29 -0800 |
commit | 09e89d538cdd7ac20bae4df6c8247e5562415453 (patch) | |
tree | 9801db4382420874dc25fd8c294b8b2a3704c5ca /lib/ansible/plugins/action | |
parent | 56c6ebe2582090ee98f0468f1b9d26dcfbf23f84 (diff) | |
download | ansible-09e89d538cdd7ac20bae4df6c8247e5562415453.tar.gz |
[stable-2.9] Add method to automatically clean up after an action plugin (#65509)
* Use correct var, move cleanup for async
* Add changelog and tests. Fixes #65393. Fixes #65277.
* Kill off all long running async tasks from listen_ports_facts
* Update task to work with older jinja2
(cherry picked from commit 03a4edb)
Co-authored-by: Matt Martz <matt@sivel.net>
Diffstat (limited to 'lib/ansible/plugins/action')
-rw-r--r-- | lib/ansible/plugins/action/__init__.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 8b70d46cff..dc72e6c56c 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -115,6 +115,18 @@ class ActionBase(with_metaclass(ABCMeta, object)): return result + def cleanup(self, force=False): + """Method to perform a clean up at the end of an action plugin execution + + By default this is designed to clean up the shell tmpdir, and is toggled based on whether + async is in use + + Action plugins may override this if they deem necessary, but should still call this method + via super + """ + if force or not self._task.async_val: + self._remove_tmp_path(self._connection._shell.tmpdir) + def get_plugin_option(self, plugin, option, default=None): """Helper to get an option from a plugin without having to use the try/except dance everywhere to set a default |