I have registered more that 500 Nodes (both linux and windows) to chef automate server and my work is to retrieve all the information of each node like plate from os version host name ip and etc … i tried using cookbook but i need more information so i tried ohai command where i am able get information as i required but here lies the problem as im getting the information on Json format its like pain in the neck while converting that to CSV…as the file size too large(50Mb) i am unable to covert it and get the desired output in well organized structured format…
is there any command in knife utility so that i can pull up this record or any procedure or script to perform this action please help…
knife search "node:*" -a memory.free -a os
foobar:
memory.free: 2173164kB
os: windows
Then pipe that to a file. Converting from JSON to CSV will be tricky as you have discovered since CSV by nature only allow for a single level of structure, whereas json allows for nested data.
If you can get the data as a single level of json, it should be much easier to convert to CSV.
knife search "node:*" -a memory.free -a os -F json
I have been using this command to pull up all the node information "knife search '.' --format=json >node.json" but the result output is a huge file is thereany way so that i can enter required ips in a file and do a for loop for that file ...wilol it will be possible??
example:
for i incat /tmp/chef1 (in chef1 file i give like 100 ips)
do
knife search 'i' --format=json >node.json
done
will this work ? or can you help me in suggesting any script?
$ knife search node 'name:node*' -a name -a memory.free -a os -F pp
33 items found
{"name"=>"node1, "memory.free"=>"155184kB", "os"=>"linux"}
{"name"=>"node2", "memory.free"=>"940616kB", "os"=>"linux"}
Which is probably easier to parse. You may also use knife exec to run pure ruby and do something like this: