Using databag in recipe

hi @rajanarkenbout

There are cookbooks out there that already do this, users springs to mind.

The structure in the data bag is the same as a Ruby hash, therefore you can use each_pair

users_databag = data_bag('mongodb', item)
users_databag.each_pair do | user, values |
log "user #{user} id #{values['id']} password #{values['password']}"
end

Hope this helps

1 Like