refactoring async

- centralized skipping
- also fixed module name broken by previous refactor
- let action modules handle async processing
- moved async into base action class's module exec
- action plugins can now run final action as async
- actually skip copy if base skips
- fixed normal for new paths
- ensure internal stat is never async
- default poll to 10 as per docs
- added hint for callback fix on poll
- restructured late tmp, now a pipeline query
- moving action handler to connection as networking does
- fixed network assumption invocation is always passed
- centralized key cleanup, normalized internal var
- _supress_tmpdir_delete now in _ansible_xxx and gets removed from results
- delay internal key removal till after we use em
- nicer tmp removing, using existing methods
- moved cleanup tmp flag to mking tmp func
This commit is contained in:
Brian Coca 2016-12-14 12:52:18 -05:00 committed by Brian Coca
parent 22db51f15c
commit c86a17b7a0
22 changed files with 254 additions and 371 deletions

View file

@ -79,16 +79,17 @@ class ActionModule(ActionBase):
return temp_path
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
self._supports_check_mode = False
result = super(ActionModule, self).run(tmp, task_vars)
if self._play_context.check_mode:
result['skipped'] = True
result['msg'] = "skipped, this module does not support check_mode."
if result.get('skipped', False):
return result
if task_vars is None:
task_vars = dict()
src = self._task.args.get('src', None)
dest = self._task.args.get('dest', None)
delimiter = self._task.args.get('delimiter', None)
@ -102,7 +103,6 @@ class ActionModule(ActionBase):
result['msg'] = "src and dest are required"
return result
remote_user = self._play_context.remote_user
if boolean(remote_src):
result.update(self._execute_module(tmp=tmp, task_vars=task_vars))
return result
@ -115,8 +115,7 @@ class ActionModule(ActionBase):
return result
if not tmp:
tmp = self._make_tmp_path(remote_user)
self._cleanup_remote_tmp = True
tmp = self._make_tmp_path()
if not os.path.isdir(src):
result['failed'] = True
@ -160,7 +159,7 @@ class ActionModule(ActionBase):
xfered = self._transfer_file(path, remote_path)
# fix file permissions when the copy is done as a different user
self._fixup_perms2((tmp, remote_path), remote_user)
self._fixup_perms2((tmp, remote_path))
new_module_args.update( dict( src=xfered,))