mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
New keyword: ignore_unreachable (#43857)
This commit is contained in:
parent
2603604fd6
commit
653d9c0f87
15 changed files with 129 additions and 2 deletions
|
@ -574,6 +574,7 @@ class Base(FieldAttributeBase):
|
|||
_no_log = FieldAttribute(isa='bool')
|
||||
_run_once = FieldAttribute(isa='bool')
|
||||
_ignore_errors = FieldAttribute(isa='bool')
|
||||
_ignore_unreachable = FieldAttribute(isa='bool')
|
||||
_check_mode = FieldAttribute(isa='bool')
|
||||
_diff = FieldAttribute(isa='bool')
|
||||
_any_errors_fatal = FieldAttribute(isa='bool')
|
||||
|
|
|
@ -511,8 +511,13 @@ class StrategyBase:
|
|||
self._tqm._stats.increment('changed', original_host.name)
|
||||
self._tqm.send_callback('v2_runner_on_failed', task_result, ignore_errors=ignore_errors)
|
||||
elif task_result.is_unreachable():
|
||||
self._tqm._unreachable_hosts[original_host.name] = True
|
||||
iterator._play._removed_hosts.append(original_host.name)
|
||||
ignore_unreachable = original_task.ignore_unreachable
|
||||
if not ignore_unreachable:
|
||||
self._tqm._unreachable_hosts[original_host.name] = True
|
||||
iterator._play._removed_hosts.append(original_host.name)
|
||||
else:
|
||||
self._tqm._stats.increment('skipped', original_host.name)
|
||||
task_result._result['skip_reason'] = 'Host %s is unreachable' % original_host.name
|
||||
self._tqm._stats.increment('dark', original_host.name)
|
||||
self._tqm.send_callback('v2_runner_on_unreachable', task_result)
|
||||
elif task_result.is_skipped():
|
||||
|
|
|
@ -45,6 +45,18 @@ def success(result):
|
|||
return not failed(result)
|
||||
|
||||
|
||||
def unreachable(result):
|
||||
''' Test if task result yields unreachable '''
|
||||
if not isinstance(result, MutableMapping):
|
||||
raise errors.AnsibleFilterError("The 'unreachable' test expects a dictionary")
|
||||
return result.get('unreachable', False)
|
||||
|
||||
|
||||
def reachable(result):
|
||||
''' Test if task result yields reachable '''
|
||||
return not unreachable(result)
|
||||
|
||||
|
||||
def changed(result):
|
||||
''' Test if task result yields changed '''
|
||||
if not isinstance(result, MutableMapping):
|
||||
|
@ -150,6 +162,8 @@ class TestModule(object):
|
|||
'succeeded': success,
|
||||
'success': success,
|
||||
'successful': success,
|
||||
'reachable': reachable,
|
||||
'unreachable': unreachable,
|
||||
|
||||
# changed testing
|
||||
'changed': changed,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue