Managing Data bags in different environments Hi I got stuck with one of the scenario, I have two environments Dev and Prod. I need to pass different values in dev and different vales in prod. So how can I manage it using one Data bag. this is my general Data bag in dev environment

I am using this data bag in Dev environment, so I have to pass different username, passwd and jdbc password for prod environment. How can I do this? I am planning to do in below manner

{
 "id": "some_data_bag_item",
 "production" : {
 "id":"Databag_item",
 "username": "username",
 "passwd": "****",
 "jdbc_password": "****"
}
 },
  "testing" : {
    "id":"Databag_item",
    "username": "username",
    "passwd": "****",
    "jdbc_password": "****
  }
 }


Is this is a right way? Do we need to add anything else in recipe? Do chef will find out which environment it is automatically?
https://www.digitalocean.com/community/tutorials/how-to-use-roles-and-environments-in-chef-to-control-server-configurations


  For instance, if a node is in the "production" environment, you could
  want to run a special recipe in your "nginx" cookbook to bring that
  server up to production policy requirements. You could also have a
  recipe in the nginx cookbook meant to configure special changes for
  testing servers.


Example


name "web_server"
description "A role to configure our front-line web servers"
run_list "recipe[apt]", "recipe[nginx]"
env_run_lists "production" =&gt; ["recipe[nginx::config_prod]"], "testing" =&gt; ["recipe[nginx::config_test]"]