Implement test.ping

Wait for minions to respond to test.ping before attempting a state.apply.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-05-21 10:42:09 +02:00
parent 3ad04b0e1a
commit f2e6df7448
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57

View File

@ -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)