mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #996 from dhozac/keep-unsuccessful-result
Keep result pristine for ignore_errors
This commit is contained in:
commit
758f172027
3 changed files with 4 additions and 8 deletions
|
@ -76,11 +76,12 @@ class AggregateStats(object):
|
||||||
prev = (getattr(self, what)).get(host, 0)
|
prev = (getattr(self, what)).get(host, 0)
|
||||||
getattr(self, what)[host] = prev+1
|
getattr(self, what)[host] = prev+1
|
||||||
|
|
||||||
def compute(self, runner_results, setup=False, poll=False):
|
def compute(self, runner_results, setup=False, poll=False, ignore_errors=False):
|
||||||
''' walk through all results and increment stats '''
|
''' walk through all results and increment stats '''
|
||||||
|
|
||||||
for (host, value) in runner_results.get('contacted', {}).iteritems():
|
for (host, value) in runner_results.get('contacted', {}).iteritems():
|
||||||
if ('failed' in value and bool(value['failed'])) or ('rc' in value and value['rc'] != 0):
|
if not ignore_errors and (('failed' in value and bool(value['failed'])) or
|
||||||
|
('rc' in value and value['rc'] != 0)):
|
||||||
self._increment('failures', host)
|
self._increment('failures', host)
|
||||||
elif 'skipped' in value and bool(value['skipped']):
|
elif 'skipped' in value and bool(value['skipped']):
|
||||||
self._increment('skipped', host)
|
self._increment('skipped', host)
|
||||||
|
|
|
@ -246,7 +246,7 @@ class PlayBook(object):
|
||||||
if results is None:
|
if results is None:
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
self.stats.compute(results)
|
self.stats.compute(results, ignore_errors=task.ignore_errors)
|
||||||
|
|
||||||
# add facts to the global setup cache
|
# add facts to the global setup cache
|
||||||
for host, result in results['contacted'].iteritems():
|
for host, result in results['contacted'].iteritems():
|
||||||
|
|
|
@ -616,11 +616,6 @@ class Runner(object):
|
||||||
elif not result.is_successful():
|
elif not result.is_successful():
|
||||||
ignore_errors = self.module_vars.get('ignore_errors', False)
|
ignore_errors = self.module_vars.get('ignore_errors', False)
|
||||||
self.callbacks.on_failed(host, data, ignore_errors)
|
self.callbacks.on_failed(host, data, ignore_errors)
|
||||||
if ignore_errors:
|
|
||||||
if 'failed' in result.result:
|
|
||||||
result.result['failed'] = False
|
|
||||||
if 'rc' in result.result:
|
|
||||||
result.result['rc'] = 0
|
|
||||||
else:
|
else:
|
||||||
self.callbacks.on_ok(host, data)
|
self.callbacks.on_ok(host, data)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue