Commit 19386c43 by Michael DeHaan

Merge

parent d1058222
...@@ -211,16 +211,6 @@ been retried for 5 times with a delay of 10 seconds. The default value for "retr ...@@ -211,16 +211,6 @@ been retried for 5 times with a delay of 10 seconds. The default value for "retr
The task returns the results returned by the last task run. The results of individual retries can be viewed by -vv option. The task returns the results returned by the last task run. The results of individual retries can be viewed by -vv option.
The registered variable will also have a new key "attempts" which will have the number of the retries for the task. The registered variable will also have a new key "attempts" which will have the number of the retries for the task.
The Do/Until feature does not take decision on whether to fail or pass the play when the maximum retries are completed, the user can
can do that in the next task as follows::
- action: shell /usr/bin/foo
register: result
until: result.stdout.find("all systems go") != -1
retries: 5
delay: 10
failed_when: result.attempts == 5
.. seealso:: .. seealso::
:doc:`playbooks` :doc:`playbooks`
...@@ -239,6 +229,3 @@ can do that in the next task as follows:: ...@@ -239,6 +229,3 @@ can do that in the next task as follows::
#ansible IRC chat channel #ansible IRC chat channel
...@@ -660,7 +660,7 @@ class Runner(object): ...@@ -660,7 +660,7 @@ class Runner(object):
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args) result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
# Code for do until feature # Code for do until feature
until = self.module_vars.get('until', None) until = self.module_vars.get('until', None)
if until is not None and result.comm_ok: if until is not None and result.comm_ok and "failed" not in result.result:
inject[self.module_vars.get('register')] = result.result inject[self.module_vars.get('register')] = result.result
cond = template.template(self.basedir, until, inject, expand_lists=False) cond = template.template(self.basedir, until, inject, expand_lists=False)
if not utils.check_conditional(cond, self.basedir, inject, fail_on_undefined=self.error_on_undefined_vars): if not utils.check_conditional(cond, self.basedir, inject, fail_on_undefined=self.error_on_undefined_vars):
...@@ -674,12 +674,15 @@ class Runner(object): ...@@ -674,12 +674,15 @@ class Runner(object):
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args) result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
result.result['attempts'] = x result.result['attempts'] = x
vv("Result from run %i is: %s" % (x, result.result)) vv("Result from run %i is: %s" % (x, result.result))
if not result.comm_ok: if "failed" in result.result:
break break
inject[self.module_vars.get('register')] = result.result inject[self.module_vars.get('register')] = result.result
cond = template.template(self.basedir, until, inject, expand_lists=False) cond = template.template(self.basedir, until, inject, expand_lists=False)
if utils.check_conditional(cond, self.basedir, inject, fail_on_undefined=self.error_on_undefined_vars): if utils.check_conditional(cond, self.basedir, inject, fail_on_undefined=self.error_on_undefined_vars):
break break
if result.result['attempts'] == retries and not utils.check_conditional(cond, self.basedir, inject, fail_on_undefined=self.error_on_undefined_vars):
result.result['failed'] = True
result.result['msg'] = "Task failed as maximum retries was encountered"
else: else:
result.result['attempts'] = 0 result.result['attempts'] = 0
conn.close() conn.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment