Merge branch 'do_until_14' of https://github.com/bennojoy/ansible into bennojoy-do_until_14

This commit is contained in:
James Cammarata 2013-09-25 15:49:14 -05:00
commit 202c4f5294
3 changed files with 70 additions and 4 deletions

View file

@ -658,7 +658,30 @@ 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:
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):
retries = self.module_vars.get('retries')
delay = self.module_vars.get('delay')
for x in range(1, retries + 1):
time.sleep(delay)
tmp = ''
if getattr(handler, 'NEEDS_TMPPATH', True):
tmp = self._make_tmp_path(conn)
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:
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;
else:
result.result['attempts'] = 0
conn.close()
if not result.comm_ok: