Skip to content

Instantly share code, notes, and snippets.

@daharon
Created July 27, 2011 17:06
Show Gist options
  • Save daharon/1109854 to your computer and use it in GitHub Desktop.
Save daharon/1109854 to your computer and use it in GitHub Desktop.
Trying to search with PyChef.
#!/usr/bin/env python
from chef import ChefAPI, Search, Node
host = 'http://10.1.1.110:4000'
key = '/tmp/daharon.office.pem'
user = 'daharon'
with ChefAPI(host, key, user):
n = Node('daharon12.office.sazze.com')
print "%s has IP %s" % ( n['hostname'], n['ipaddress'] )
results = Search('node').query('roles:office_webserver')
print 'Search URL: ', results.url
print 'Total results: ', results.total
for node in results:
print node['automatic']['hostname']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment