Skip to content

Instantly share code, notes, and snippets.

@zygiss
Created August 5, 2015 19:27
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 zygiss/4f027545021de43468be to your computer and use it in GitHub Desktop.
Save zygiss/4f027545021de43468be to your computer and use it in GitHub Desktop.
Retrieve list of states applicable to a minion
from sys import argv
import salt.client
local = salt.client.LocalClient()
minion = str(argv[1])
states = []
result = local.cmd(minion, 'state.show_highstate')
for dict in result[minion].itervalues():
try:
states.index(dict['__sls__'])
except ValueError:
states.append(dict['__sls__'])
print sorted(states)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment