diff --git a/scullery.py b/scullery.py index 3c19048..2ccaef3 100755 --- a/scullery.py +++ b/scullery.py @@ -141,11 +141,21 @@ def vagrant_sshconfig(outfile): with open(outfile, 'w') as fh: fh.write(ssh_config) -def runapply(state, target): +def _saltcmd(target): if target == 'local': saltcmd = 'salt-call --local' else: - saltcmd = 'salt {}'.format(target) + saltcmd = 'salt -t10 {}'.format(target) + return saltcmd + +def runping(target): + saltcmd = _saltcmd(target) + sshout = v.ssh(command='sudo {} test.ping'.format(saltcmd)) + log.info('\n{}\n'.format(str(sshout))) + return sshout + +def runapply(state, target): + saltcmd = _saltcmd(target) sshout = v.ssh(command='sudo {} state.apply {}'.format(saltcmd, state)) log.info('\n{}\n'.format(str(sshout))) @@ -241,6 +251,11 @@ def main_interactive(): log.debug('state.apply requested') if masters is not None: target = 'scullery-*' + count = 0 + while not runping(target): + if count == 5: + _abort('Unable to reach minions') + count += 1 else: target = 'local' runapply(testconf['apply'], target)