CoderSpinoza
CoderSpinoza

Reputation: 2165

Resolving Chef Dependencies

In my lab, I am currently managing a 20 nodes cluster with Cobbler and Chef. Cobbler is used for OS provisioning and basic network settings, which is working fine as expected. I can manage several OS distributions with preseed-based NQA installation and local repo mirroring.

We also successfully installed chef server and started managing nodes but chef is not working as I expected. The issue is that I am not being able to set node dependencies within chef. Our one important use case is this:

  1. We are setting up ceph and openstack on these nodes
  2. Ceph should be installed before openstack because openstack uses ceph as back-end storage
  3. Ceph monitor should be installed before Ceph osd because creating osd requires talking to monitor

The dependencies between Openstack and Ceph does not matter because it is a dependency in one node; just installing openstack later would resolve the issue. However, a problem arises with the dependency between ceph monitor and ceph osd. Ceph osd provisioning requires a running ceph monitor. Therefore, ceph osd recipe should always be run after ceph mon recipe finishes in another node. Our current method is just to run "chef-client" in "ceph-osd" node after "chef-client" run completely finishes in "ceph-mon" node but I think this is a too much of a hassle. Is there a way to set these dependencies in Chef so that nodes will provision sequentially according to their dependencies? If not, are there good frameworks who handles this?

Upvotes: 0

Views: 72

Answers (1)

Tensibai
Tensibai

Reputation: 15784

In chef itself, I know no method for orchestrating (that's not chef Job).

A workaround given your use case could be to use tags and search.

You monitor recipe could tag the node at end (with tag("CephMonitor") or with setting any attribute you wish to search on).

After that the solr index of chef has to catch it up (usually in the minute) and you can use search in the Cephosd recipe you can do something like this:

CephMonitor = search(:node,"tags:CephMonitor") || nil

return if CephMonitor.nil?

[.. rest of the CephOsd recipe, using the CephMonitor['fqdn'] or other attribute from the node ..]

The same behavior can be used to avoid trying to run the OpenStack recipe until the osd has run.

The drawback if that it will take 2 or 3 chef run to get to a converged infrastructure.

I've nothing to recommend to do the orchestration, zookeeper or consul could help instead of tags and to trigger the runs.

Rundeck can tage the runs on different nodes and aggregate this in one job.

Which is best depends on your feeling there.

Upvotes: 1

Related Questions