Skip to content

Instantly share code, notes, and snippets.

@tystr
Created July 31, 2014 23:52
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 tystr/dadda60cc5ab1861a2e6 to your computer and use it in GitHub Desktop.
Save tystr/dadda60cc5ab1861a2e6 to your computer and use it in GitHub Desktop.
def get_hosts_for_role(role, puppetmaster="puppetmaster.mydomain.net"):
""" Query the puppetmaster for hosts of nodes whose server_role fact matches the given role """
return yaml.load(local('ssh -T {0} \'curl -s -k -H "Accept: yaml" https://localhost:8140/production/facts_search/search?facts.server_role={1}\' | awk \'!/baseami/\''.format(puppetmaster, role), capture=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment