I have a server managed by Chef. I need to access some values that live in a cookbook data bag from scripts not run by Chef.
/* Chef REST API allows to access data bag values as seen by Chef server. This is not what I want. Each chef-client
run may introduce a number of coordinated changes, including changes in the data bag. If data on the server had already changed but chef-client
did not run locally yet, local setup and server-side data bag may be out of sync. */
I see two solutions:
/var/cache/chef/cookbooks/<book-name>
since it's more or less normal Ruby.Are there better options?
Dumping data from the node hash or data bags into a separate file is a good way of communicating between the Chef server and scripts running on a node. If your script can parse JSON then it's really easy:
file "/etc/script.json" do
owner "root"
group "root"
mode 0644
content node[:whatever].to_json
end
Using the Chef REST interface sounds like overkill, and groping around in /var/cache/chef is just rude. (-:
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