当前位置: 动力学知识库 > 问答 > 编程问答 >

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:

  • How do I design a recipe for apache service to dynamically update the databag?
  • How do I design the web service recipe to get the dynamically updated information from the databag?

Or, is there any other way to do this?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: