Created
July 27, 2011 17:06
-
-
Save daharon/1109854 to your computer and use it in GitHub Desktop.
Trying to search with PyChef.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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