red888
red888

Reputation: 31520

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?

Upvotes: 2

Views: 2894

Answers (2)

coderanger
coderanger

Reputation: 54181

knife search '*:*' --format=json is probably more of what you want. Also check out knife download nodes/ to get them as files.

Upvotes: 4

Kurt McAlpine
Kurt McAlpine

Reputation: 93

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

Upvotes: 0

Related Questions