austinheiman
austinheiman

Reputation: 1009

Drop databag on node as is (json files in a dir)

Say I have this chef data bag:

- data_bags
    -  things
        -  alpha.json
        -  bravo.json
        -  charlie.json

How can I drop the things data bag as is (a dir with three json files) into /tmp/things on a node using a recipe? Currently I am iterating over the things data bag with .each, reading each data bag item and then writing a json file from the returned hash. This seems silly, is there a builtin chef utility that can just drop a data bag as is onto a node?

Upvotes: 0

Views: 23

Answers (1)

coderanger
coderanger

Reputation: 54211

Nope, that would be the way to do it. You could use the search(:things, '*:*') to save a few API calls but the code structure would be the same. Bags are generally used to configure recipe code, not written to files, so there is nothing specifically for this. If you want to copy data verbatim to the file system, put it under files/ in a cookbook and use a remote_directory resource.

Upvotes: 1

Related Questions