I have registered over 100 Nodes (both linux& windows) to chef automate server , but now i need to know the information of os-version, platform and packages installed on each and every particular node in a csv file format . i know that there is a command called ohai but it gives more information which i required can any one suggest me a cookbook or a recipe to retrieve all the node information …
I would use the RUBY CSV output in combination with the Ohai Properties. This could be done a few ways, but declaring the platform agnostic properties first may be the best way, separating the Windows vs Linux properties within the if/elsif statements to allow the cookbook to be truly agnostic.
# Define operating platform from the ohai values
op_sys = node['os']
if op_sys == 'windows'
# Define platform specific data
hostname = node['hostname']
ip = node["ip_address"]
# Now the csv part, and filling the data
require "csv"
CSV.open("file.csv", "wb") do |csv|
csv << ["hostname", "operatingsystem", "IP"]
csv << ["#{hostname}", "#{op_sys}", "#{ip}"]
end
elsif op_sys == 'linux'
# Define platform specific data
CSV.open("file.csv", "wb") do |csv|
# some more code/logic for linux
end
end
Here are some basic details about the ohai properties
*** I DID NOT TEST THIS, SO YOU MAY NEED TO FINE TUNE***