karunakar
karunakar

Reputation: 327

Dynamically get information from Databags -Chef

I'm using chef-version [Chef: 10.14.4]. I would like to create several recipes, that read and write dynamic information to and from a databag about different services running on different servers.

Here's an example:

  1. I'm running an apache service on server1, server2 and server3.
  2. Now, in one of my recipe for server1, I would like to start/execute a web service, but before doing that I need to make sure server1, server2 and server3 are running apache service.

Questions are:

Or, is there any other way to do this?

Upvotes: 1

Views: 405

Answers (1)

Draco Ater
Draco Ater

Reputation: 21226

You don't have to use databags to let one server to know about the other. Use search. You can search the nodes by attributes, recipes, tags and so on. In your case you can search for nodes that have your apache service in run list. If you get all 3 nodes as a result of search, then hopefully they have apache running.

If you still want/need to update databags from your recipe, see Creating and Editing Data Bags within a Recipe in Data Bags help.

Upvotes: 1

Related Questions