I'm trying to manage a chef role as below.
In this case the attribute node["customer"]["name"] is an array.
In the recipe I need to get the value of the first element of the array node["customer"]["name"] as "foo".
"customer" => {
"name" => {
["foo"] => {
"prod" => {
"apache" => {
"listening" => 81
},
"database" => {
"type" => "postgres"
}
},
"dev" => {
"apache" => {
"listening" => 81
},
"database" => {
"type" => "postgres"
}
}
}
}
}
What I have done:
node[:customer][:name].each do |customer|
Chef::Log.info("CONFIGURING --- #{customer}")
end
But unexpectly, the variable "customer" contain the value
INFO: CONFIGURING --- ["[\"foo\"]", {"prod"=>{"apache"=>{"listening"=>81}, "database"=>{"type"=>"postgres"}}, "dev"=>{"apache"=>{"listening"=>81}, "database"=>{"type"=>"postgres"}}}]
instead of just simple value "foo"
How can i get the simple value "foo" instead of the whole recursive hash?
Thanks