Skip to content

Instantly share code, notes, and snippets.

@stbenjam
Last active August 29, 2015 14:19
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 stbenjam/30868e675d0eeae8d337 to your computer and use it in GitHub Desktop.
Save stbenjam/30868e675d0eeae8d337 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
import os
import sys
import salt.config
import salt.runner
if __name__ == '__main__':
__opts__ = salt.config.master_config(
os.environ.get('SALT_MASTER_CONFIG', '/etc/salt/minion'))
runner = salt.runner.Runner(__opts__)
stdout_bak = sys.stdout
with open(os.devnull, 'wb') as f:
sys.stdout = f
ret = runner.cmd('cache.grains', [os.environ.get('SALT_MINION')]
sys.stdout = stdout_bak
print json.dumps(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment