Chef Attributes, How to get the value of a specific key -


i'm trying manage chef role below.
in case attribute node["customer"]["name"] array.
in recipe need value of first element of array node["customer"]["name"] "foo".

"customer" => {     "name" => {         ["foo"] => {             "prod" => {                 "apache" => {                     "listening" => 81                 },                 "database" => {                     "type" => "postgres"                 }             },             "dev" => {                 "apache" => {                     "listening" => 81                 },                 "database" => {                     "type" => "postgres"                 }             }         }     } } 

what have done:

node[:customer][:name].each |customer| chef::log.info("configuring --- #{customer}") end 

but unexpectly, variable "customer" contain value

info: configuring --- ["[\"foo\"]", {"prod"=>{"apache"=>{"listening"=>81}, "database"=>{"type"=>"postgres"}}, "dev"=>{"apache"=>{"listening"=>81}, "database"=>{"type"=>"postgres"}}}]

instead of simple value "foo"

how can simple value "foo" instead of whole recursive hash?

thanks

node[:customer][:name].each |customer,properties|   chef::log.info("configuring --- #{customer}") end 

you're using ruby there iterate on hash, have tell ruby don't wish full object key , else rest of properties.


Comments