Data bags
A data bag is a global variable that's stored as JSON data and is accessible from a Chef server or chef-solo. A Chef server indexes a data bag, and hence it can be searched using Chef API. Recipes can also search a data bag and access its items.
A data bag has the following structure:
{ "id": "item_name", "key_1": "value_1", . . . "key_n": "value_n" }
Before an item can be uploaded to a data bag, a directory structure needs to be put in place to store the JSON files. In chef-repo
, create a directory structure as follows:
chef-repo |-- cookbooks |-- data_bags |-- environments '-- roles
All the data bags will get stored in the data_bags
directory. Let's say we've a data bag called users
that will be used to store information such as the name, SSH key, and home directory of different users. This will require us to create a directory structure as follows:
chef-repo/data_bags |-- users
All the...