Skip to content

Instantly share code, notes, and snippets.

@moali87
Created August 12, 2015 15:42
Show Gist options
  • Select an option

  • Save moali87/e5ffca005c1c36edd8ec to your computer and use it in GitHub Desktop.

Select an option

Save moali87/e5ffca005c1c36edd8ec to your computer and use it in GitHub Desktop.
__author__ = 'Akhter Ali'
__date__ = '08/12/15'
__version__ = '0.1.0'
try:
import salt.cloud
CLOUDIMPORTED = True
print('salt.cloud successfully imported')
except ImportError:
CLOUDIMPORTED = False
print('Error: salt.cloud was not imported')
def __virtual__():
'''
Only for machines running more than 5 minutes
'''
# return 'checkhighstate' if __grains__['uptime_minutes'] > 7 else False
if CLOUDIMPORTED:
return 'checkhighstate_test'
return False
# Return may need to return a text rather than a boolean
def destroy():
'''
Destroy minion if __virtual__ is True
CLI Example::
.. code-block:: bash
salt '*' checkhighstate_test.destroy
'''
client = salt.cloud.CloudClient('/etc/salt/cloud')
minion_name = __grains__['id']
client.destroy(names=[minion_name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment