mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge
This commit is contained in:
parent
d10582225b
commit
19386c43a7
2 changed files with 5 additions and 15 deletions
|
@ -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 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::
|
||||
|
||||
:doc:`playbooks`
|
||||
|
@ -239,6 +229,3 @@ can do that in the next task as follows::
|
|||
#ansible IRC chat channel
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -660,7 +660,7 @@ class Runner(object):
|
|||
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
||||
# Code for do until feature
|
||||
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
|
||||
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):
|
||||
|
@ -674,12 +674,15 @@ class Runner(object):
|
|||
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
||||
result.result['attempts'] = x
|
||||
vv("Result from run %i is: %s" % (x, result.result))
|
||||
if not result.comm_ok:
|
||||
if "failed" in result.result:
|
||||
break
|
||||
inject[self.module_vars.get('register')] = result.result
|
||||
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):
|
||||
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:
|
||||
result.result['attempts'] = 0
|
||||
conn.close()
|
||||
|
|
Loading…
Reference in a new issue