From 6ba43311619e814ca41025c8c8da0f6784e3b30c Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 6 Aug 2013 12:42:30 -0400 Subject: [PATCH] Correctly check for failed status from an async task. Use runner_on_async_failed callback (instead of runner_on_failed) when an async task times out. Add runner_on_async_ok callback when a task is started in fire and forget mode. --- lib/ansible/playbook/__init__.py | 5 ++++- lib/ansible/runner/poller.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 3f3c8e546a..716ac597b1 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -277,7 +277,7 @@ class PlayBook(object): # since these likely got killed by async_wrapper for host in poller.hosts_to_poll: reason = { 'failed' : 1, 'rc' : None, 'msg' : 'timed out' } - self.runner_callbacks.on_failed(host, reason) + self.runner_callbacks.on_async_failed(host, reason, poller.jid) results['contacted'][host] = reason return results @@ -319,6 +319,9 @@ class PlayBook(object): if task.async_poll_interval > 0: # if not polling, playbook requested fire and forget, so don't poll results = self._async_poll(poller, task.async_seconds, task.async_poll_interval) + else: + for (host, res) in results.get('contacted', {}).iteritems(): + self.runner_callbacks.on_async_ok(host, res, poller.jid) contacted = results.get('contacted',{}) dark = results.get('dark', {}) diff --git a/lib/ansible/runner/poller.py b/lib/ansible/runner/poller.py index d6d6fc7388..206868e1f7 100644 --- a/lib/ansible/runner/poller.py +++ b/lib/ansible/runner/poller.py @@ -73,7 +73,7 @@ class AsyncPoller(object): else: self.results['contacted'][host] = res poll_results['contacted'][host] = res - if 'failed' in res: + if res.get('failed', False) or res.get('rc', 0) != 0: self.runner.callbacks.on_async_failed(host, res, self.jid) else: self.runner.callbacks.on_async_ok(host, res, self.jid)