Reputation: 40904
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?
Upvotes: 8
Views: 2662
Reputation: 2457
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. (-:
Upvotes: 7