Skip to content

Instantly share code, notes, and snippets.

@basepi
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basepi/e5d0013406c6f79f13b3 to your computer and use it in GitHub Desktop.
Save basepi/e5d0013406c6f79f13b3 to your computer and use it in GitHub Desktop.
#!py
# -*- coding: utf-8 -*-
import logging
import salt.client as salt_client
def run():
"""EdgeCast Pending Auth"""
logger = logging.getLogger(__name__)
logger.trace("Handling minion event with data : %s", data)
# check type of event
if 'act' not in data:
logger.trace("Event does not have an 'act' field, so ignoring it")
return {}
minion_id = data['id']
local = salt_client.LocalClient()
""" run sync_all to load all files to minion """
local.cmd(minion_id, 'saltutil.sync_all')
""" refresh pillars to get uber data for new minion """
local.cmd(minion_id, 'saltutil.refresh_pillar')
""" run global.minion.state """
local.cmd(minion_id, 'state.sls', ['global.minion'])
""" run global state """
local.cmd(minion_id, 'state.sls', 'global')
if __name__ == '__main__':
run()
#What i want to do is python
CMD="salt '${SERVER}' system.reboot && salt-run state.event 'salt/minion/${SERVER}/start' count=1 quiet=True && salt '${SERVER}' st
ate.highstate"
eval ${CMD}
RET=$?
if [ $RET == 0 ];then
echo " server looks a ok "
else
echo " server failed the highstate after reboot "
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment