Skip to content

Instantly share code, notes, and snippets.

@bochi
Created November 2, 2020 14:16
Show Gist options
  • Save bochi/019a54c7aa3782e2447c1347490e81b8 to your computer and use it in GitHub Desktop.
Save bochi/019a54c7aa3782e2447c1347490e81b8 to your computer and use it in GitHub Desktop.
for i in range(retry_int['attempts']):
# in case no otp is given by the state, get it from pillar
# this should happen within the loop, in case otp changes
if not otp:
try:
log.debug('Trying to get otp from pillar %s...' % pillar_key)
otp = __salt__['pillar.get'](pillar_key)[-1]
# if getting the otp from pillar fails, ask the master to generate a new one
except IndexError:
log.debug('Unable to get otp from pillar, otp is %s' % otp)
_send_salt_event('newotp')
log.debug('sleeping for %d seconds' % retry_int['interval'] )
time.sleep(retry_int['interval'])
else:
log.debug('Success! OTP is %s' % otp)
log.debug('trying to join #%d' % i )
result = _do_join(computername, realm, otp, server)
if result[0]:
break
log.debug('sleeping for %d seconds' % retry_int['interval'] )
time.sleep(retry_int['interval'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment