I have a role_multi_module.json
which is a chef role which contains a array in JSON format.
Role name: role_multi_module.json
{
"name": "role_multi_module",
"default_attributes": {
"cloud": {
"global": false
}
},
"override_attributes": {},
"json_class": "Chef::Role",
"description": "This is just a test role, no big deal.",
"employees": [{
"name": "Ram",
"email": "ram@gmail.com",
"age": 23
},
{
"name": "Shyam",
"email": "shyam23@gmail.com",
"age": 28
}
],
"chef_type": "role",
"run_list": ["recipe[hello-chef]"]
}
Using the below recipe I'm able to get only one employee details i.e. the second one.
Recipe name: multi.rb
execute 'test-multi-module' do
node['role_multi_module']['employees'].each do |employee|
command "echo #{employees['name']} #{employees['email']}}"
end
end
How to iterate the JSON array of 2 employees from the above recipe?