How do I get all node objects from chef server in the form of json?
I can use this command to return one node object from chef server:
knife node show -l --format=json <node_name>
I want to get all node objects (as json) to be able to write my own reports.
Is there a way to query the chef DB directly?
knife search '*:*' --format=json is probably more of what you want. Also check out knife download nodes/ to get them as files.
With the help of unix pipe we can achieve this very easily.
Getting all the nodes names is easy
knife node list
Combine with some filter
knife node list | grep myhost
Get the node for all the hosts your are interested in
knife node list | grep myhost | xargs -n 1 knife node show -l -Fj