mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
moved to exceptions for basic skip/fails
better handling of checkmode and async fix test to follow new flow control
This commit is contained in:
@@ -30,7 +30,7 @@ import time
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleActionSkip, AnsibleActionFail
|
||||
from ansible.executor.module_common import modify_module, build_windows_module_payload
|
||||
from ansible.module_utils.json_utils import _filter_non_json_lines
|
||||
from ansible.module_utils.six import binary_type, string_types, text_type, iteritems, with_metaclass
|
||||
@@ -93,14 +93,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||
result = {}
|
||||
|
||||
if self._task.async and not self._supports_async:
|
||||
result['msg'] = 'async is not supported for this task.'
|
||||
result['failed'] = True
|
||||
raise AnsibleActionFail('async is not supported for this task.')
|
||||
elif self._play_context.check_mode and not self._supports_check_mode:
|
||||
result['msg'] = 'check mode is not supported for this task.'
|
||||
result['skipped'] = True
|
||||
raise AnsibleActionSkip('check mode is not supported for this task.')
|
||||
elif self._task.async and self._play_context.check_mode:
|
||||
result['msg'] = 'check mode and async cannot be used on same task.'
|
||||
result['failed'] = True
|
||||
raise AnsibleActionFail('check mode and async cannot be used on same task.')
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
# Parse out any hostname:port patterns
|
||||
new_name = self._task.args.get('name', self._task.args.get('hostname', None))
|
||||
display.vv("creating host via 'add_host': hostname=%s" % new_name)
|
||||
|
||||
@@ -84,9 +84,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
|
||||
@@ -40,9 +40,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
source = self._task.args.get('src', None)
|
||||
content = self._task.args.get('content', None)
|
||||
dest = self._task.args.get('dest', None)
|
||||
|
||||
@@ -38,9 +38,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
module = self._task.args.get('use', 'auto')
|
||||
|
||||
if module == 'auto':
|
||||
|
||||
@@ -34,9 +34,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
if not tmp:
|
||||
tmp = self._make_tmp_path()
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if result.get('skipped', False) or result.get('failed', False):
|
||||
return result
|
||||
|
||||
module = self._task.args.get('use', 'auto').lower()
|
||||
|
||||
if module == 'auto':
|
||||
|
||||
Reference in New Issue
Block a user