5353import ansible_mitogen .connection
5454import ansible_mitogen .planner
5555import ansible_mitogen .target
56+ import ansible_mitogen .utils
57+
5658from ansible .module_utils ._text import to_text
5759
5860try :
@@ -226,7 +228,7 @@ def _remove_tmp_path(self, tmp_path):
226228 with a pipelined call to :func:`ansible_mitogen.target.prune_tree`.
227229 """
228230 LOG .debug ('_remove_tmp_path(%r)' , tmp_path )
229- if tmp_path is None and ansible . __version__ > '2.6' :
231+ if tmp_path is None and ansible_mitogen . utils . ansible_version [: 2 ] >= ( 2 , 6 ) :
230232 tmp_path = self ._connection ._shell .tmpdir # 06f73ad578d
231233 if tmp_path is not None :
232234 self ._connection .get_chain ().call_no_reply (
@@ -335,7 +337,7 @@ def get_task_timeout_secs(self):
335337 def _set_temp_file_args (self , module_args , wrap_async ):
336338 # Ansible>2.5 module_utils reuses the action's temporary directory if
337339 # one exists. Older versions error if this key is present.
338- if ansible . __version__ > '2.5' :
340+ if ansible_mitogen . utils . ansible_version [: 2 ] >= ( 2 , 5 ) :
339341 if wrap_async :
340342 # Sharing is not possible with async tasks, as in that case,
341343 # the directory must outlive the action plug-in.
@@ -346,7 +348,7 @@ def _set_temp_file_args(self, module_args, wrap_async):
346348 # If _ansible_tmpdir is unset, Ansible>2.6 module_utils will use
347349 # _ansible_remote_tmp as the location to create the module's temporary
348350 # directory. Older versions error if this key is present.
349- if ansible . __version__ > '2.6' :
351+ if ansible_mitogen . utils . ansible_version [: 2 ] >= ( 2 , 6 ) :
350352 module_args ['_ansible_remote_tmp' ] = (
351353 self ._connection .get_good_temp_dir ()
352354 )
@@ -393,7 +395,7 @@ def _execute_module(self, module_name=None, module_args=None, tmp=None,
393395 )
394396 )
395397
396- if tmp and ansible . __version__ < '2.5' and delete_remote_tmp :
398+ if tmp and delete_remote_tmp and ansible_mitogen . utils . ansible_version [: 2 ] < ( 2 , 5 ) :
397399 # Built-in actions expected tmpdir to be cleaned up automatically
398400 # on _execute_module().
399401 self ._remove_tmp_path (tmp )
0 commit comments