Skip to content

Instantly share code, notes, and snippets.

@moali87
Created July 21, 2015 19:54
Show Gist options
  • Save moali87/4fcb930ac8f759db9de6 to your computer and use it in GitHub Desktop.
Save moali87/4fcb930ac8f759db9de6 to your computer and use it in GitHub Desktop.
'''
This function gathers the grains uptime_minutes and assigns it to uptime_grain, if uptime_grain is more than 7 minutes,
it will destroy the instance given by instance name provided by grains ID.
'''
def __virtual__():
'''
Only for machines running more than 7 minutes
'''
# return 'checkhighstate' if __grains__['uptime_minutes'] > 7 else False
if __grains__.get('uptime_minutes', '') < 7:
return 'False'
return 'checkhighstate'
def destroy():
'''
Destroy minion if __virtual__ is True
CLI Example::
salt '*' checkhighstate.destroy
'''
module_name = __grains__['id']
out = __salt__['cloud.destroy']('akhterpod') ###Need to igure out how to pass argument here
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment