Skip to content

Instantly share code, notes, and snippets.

@jalons
Created June 21, 2016 17:06
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 jalons/650f9686e855221751a38f03c3d0b302 to your computer and use it in GitHub Desktop.
Save jalons/650f9686e855221751a38f03c3d0b302 to your computer and use it in GitHub Desktop.
Get the members of a nodegroup, must be run from the master
#!/usr/bin/env python
import salt.config
import salt.client
opts = salt.config.master_config('/etc/salt/master')
_client = salt.client.LocalClient()
_ret = {}
for _group, _target in opts.get('nodegroups').iteritems():
_ret[_group] = _client.cmd(tgt=_target, fun='test.ping', expr_form='compound').keys()
print _ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment