1

I have data bags specific to different clients like the following:

/data_bags/client1/users/....
/data_bags/client1/projects/....
/data_bags/client2/users/...
/data_bags/client2/projects/...

So, client1 and client2 have a different set of projects and users, but me as a developer it's better if all the configurations are under folder. I work on them, then when they are production ready, I want to push them to chef server to provision the nodes. But knife.rb expects all the data bags to be under one folder i.e. /data_bags. It would be perfect If I can specify a data bag path as such:

cookbook_path            ["#{current_dir}/../cookbooks", "#{current_dir}/../other-cookbooks"]
databag_path            "#{current_dir}/../data_bags/client1"

My goal is to arrange or organize different data bags collection in a different folder and specify which bag path I want to use by knife.rb

Is there a way to specify the paths of the data bags as well?

Starx
  • 77,474
  • 47
  • 185
  • 261
  • Why? What's your goal? IIRC, you always have to provide the path to the data bag's `.json` file. You can't just access it (on disk) through the data bag name plus item. – StephenKing Jan 10 '17 at 12:52
  • That's counter productive, data bags will be uploaded to a chef-server, or you'll enter a terrible mess if you try to subdivise the chef repo pathes. The chef repo more or less mimic the internal path access via API to the chef-server objects (for example /data/ for databags, /role/ for roles). All in all, wait for your previous question to be answered before starting this one, one being a follow up from the other. – Tensibai Jan 10 '17 at 13:09
  • @Tensibai, Ok, but can you elaborate `data bags will be uploaded to a chef-server, or you'll enter a terrible mess if you try to subdivise the chef repo pathes`? I didn't get your point. – Starx Jan 10 '17 at 13:17
  • You can still store the items in different files however you wish, once on the chef server, you'll have only a pair for access, the data_bag name and the data_bag_item name, the path will be lost and can only servre in version control to arrange things. So your recipe code to access the data won't match your repo layout and you'll loose time finding back which item is what, the repo layout should be `/data_bags//.json` so you will have a match between the `data_bag_item(,)` call in your recipe and the layout in your repository. – Tensibai Jan 10 '17 at 13:22
  • @Tensibai, That is OK, I don't want to upload all different data_bags collection, I only want to specify one data_bags path that will be valid for one client. – Starx Jan 10 '17 at 13:32
  • @Starx ?????? I really don't get you there. which lead me to think it's an XY problem, asking about a non working solution but not about the problem itself. – Tensibai Jan 10 '17 at 13:34
  • Short answer, there's no way as anyway this makes no sense for the node you'll be provisionning, you can't use the same data_bag name and item name and expect to get different results... this is as if you were copying `client1/users/admins.json` to `/deploy/users/` and then `client2/users/admins.json` to `/deploy/users/` result will be everyone will have `admins.json` data from client2. – Tensibai Jan 10 '17 at 14:12
  • What does it have to do with data_bag name or item name? End goal is to upload different data bags to different clients by specifying a path for data_bags. – Starx Jan 10 '17 at 14:19
  • May be the term I want is organisations than clients. I am not sure. – Starx Jan 10 '17 at 14:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132808/discussion-between-starx-and-tensibai). – Starx Jan 10 '17 at 14:19

0 Answers0