I was trying to create a Chef data bag from within the chef-repo directory using the command:
knife data bag create users deployer
And i get the response:
Created data_bag[users]
Created data_bag_item[deployer]
But I am not able to locate the data bag users nor its data bag item. It is not in the data_bags folder or anywhere else that I could see. If I do a
knife data bag show users
It will show me the data bag item name. So it must be saved somewhere. The documentations tell me that the data bag should be in the folder chef-repo -> data_bags -> users. But my data_bags folder appears to be empty. So where is the data bag I have just created?
With Chef, there's a disparity between your local computer (called the "workstation") and the remote Chef Server. In your case, the knife
command created the data bag on the remote Chef Server.
I understand how that can be misleading. A data bag is nothing more than a folder containing one or more .json
files. Usually you generate this structure manually on your workstation (either using the GUI or terminal).
So in your example, just make the folder you've described (chef-repo -> data_bags -> users
) and then create a chef-repo/data_bags/users/deployer.json
file using the schema described by the cookbook.
When you use
knife data bag create users deployer
knife creates that data bag on chef-server. It is not available on your local chef workstation. But you can download this data bag on local workstation. Just use the following command
knife download data_bags
This command will download you data bag in chef-repo/data_bags/users/deployer.json You can go there and directly update this JSON file. When you are done, do remember to upload this data bag again with "knife upload ."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With