coderanger / pychef

Python library to interact with the Chef server API
Other
195 stars 129 forks source link

Interrogate Roles #65

Closed scottsuch closed 7 years ago

scottsuch commented 7 years ago

Is there a way to interrogate an existing role to see what it contains?

#!/usr/bin/env python3

import chef

api = chef.autoconfigure()
print('Role Attributes:')
role = chef.Role('some_role')
print(role.override_attributes)

I've run the above and it actually returns data but it seems to be a pretty dirty/not truly supported method. Is there a way to get an object that would contain similar data to what knife role show <some_role> would return?

coderanger commented 7 years ago

Can you be more specific about what "dirty" means? That should print out the dict just fine. If you want a nicely indented display, use the pprint module.

scottsuch commented 7 years ago

It just didnt' seem from the documentation that it was an officially supported method. Thanks for the clarification and the project in general, it's a lifesaver =)