From 3f31b166f6bc2bf668eebe58c866d2512572923c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 20 Jan 2019 10:50:38 +0000 Subject: [PATCH] issue #461: Ansible 2.3-compatible _get_candidate_temp_dirs(). --- ansible_mitogen/services.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index c0615c52..76d9f590 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -79,14 +79,17 @@ else: def _get_candidate_temp_dirs(): - options = ansible.constants.config.get_plugin_options('shell', 'sh') + try: + # >=2.5 + options = ansible.constants.config.get_plugin_options('shell', 'sh') + remote_tmp = options.get('remote_tmp') or ansible.constants.DEFAULT_REMOTE_TMP + system_tmpdirs = options.get('system_tmpdirs', ('/var/tmp', '/tmp')) + except AttributeError: + # 2.3 + remote_tmp = ansible.constants.DEFAULT_REMOTE_TMP + system_tmpdirs = ('/var/tmp', '/tmp') - # Pre 2.5 this came from ansible.constants. - remote_tmp = (options.get('remote_tmp') or - ansible.constants.DEFAULT_REMOTE_TMP) - dirs = list(options.get('system_tmpdirs', ('/var/tmp', '/tmp'))) - dirs.insert(0, remote_tmp) - return mitogen.utils.cast(dirs) + return mitogen.utils.cast([remote_tmp] + list(system_tmpdirs)) def key_from_dict(**kwargs):