def key_regen():
 client = salt.client.get_local_client(__opts__['conf_file'])
 try:
  client.cmd('*', 'saltutil.regen_keys')
 except SaltClientError as client_error:
  print(client_error)
  return False
 for (root, _, files) in os.walk(__opts__['pki_dir']):
  for fn_ in files:
   path = os.path.join(root, fn_)
   try:
    os.remove(path)
   except os.error:
    pass
 msg = 'The minion and master keys have been deleted.  Restart the Salt\nMaster within the next 60 seconds!!!\n\nWait for the minions to reconnect.  Once the minions reconnect\nthe new keys will appear in pending and will need to be re-\naccepted by running:\n    salt-key -A\n\nBe advised that minions not currently connected to the master\nwill not be able to reconnect and may require manual\nregeneration via a local call to\n    salt-call saltutil.regen_keys'
 return msg

def key_regen ( ) : client = salt . client . get_local_client ( __opts__ [ 'conf_file' ] ) try : client . cmd ( '*' , 'saltutil.regen_keys' ) except SaltClientError as client_error : print ( client_error ) return False for ( root , _ , files ) in os . walk ( __opts__ [ 'pki_dir' ] ) : for fn_ in files : path = os . path . join ( root , fn_ ) try : os . remove ( path ) except os . error : pass msg = 'The minion and master keys have been deleted.  Restart the Salt\nMaster within the next 60 seconds!!!\n\nWait for the minions to reconnect.  Once the minions reconnect\nthe new keys will appear in pending and will need to be re-\naccepted by running:\n    salt-key -A\n\nBe advised that minions not currently connected to the master\nwill not be able to reconnect and may require manual\nregeneration via a local call to\n    salt-call saltutil.regen_keys' return msg
this routine is used to regenerate all keys in an environment .