I assume you are new to Ruby. If yes, welcome!
The Chef search() function returns an array of Chef nodes, and you take the head of this array using the first method. To access the IP address of other nodes, use the usual array operator:
dbnodes = search(:node, "role:Db") dbnodes.each do |node| Chef::Log.info("#{node["name"]} has IP address #{node["ipaddress"]}") end
This will give you the necessary information.
Tim potter
source share