-iom-

Contributing, no matter how small, feels good.

posted: 20 Jan 2018

Hmm why are my chef cookbooks behaving so strangely?

This is the question we were asking ourselves the day we updated our docker for mac installation. What do you mean by strange you say? Well we have logic that dictates how a server is to be provisioned based on the virtualization environment the code is executing in. Since the update, the code would be unable to detect if the chef run was being executed in the context of a docker container. This is a problem.

How does Chef know in what virtualization environment it’s running?

Chef uses a library called Ohai. What this library essentially does is profiles your system and generates metadata which the engineer can leverage. When looking at this metadata we quickly noticed that the value for the system key, which would normally be docker in this scenario, is now yielding nil. We were able to identify that in this new release of docker for mac, they changed their convention for writing out the values in /proc/self/cgroup. A pattern in which Ohai uses a regular expression, which is now failing, to match for. So what do we do?

Help out and submit a Pull Request!

Instead of making the creators of Ohai aware of this issue#1110 only, let’s offer solutions.

Feels good.

Let’s say I’m a big fan of everything Opscode. And to have the opportunity to present a solution to a problem is something that I couldn’t pass up. Almost makes me feel like part of their elite team. So what of this pull request that I submitted?

Looks like we can use the new docker for mac install now.

Feels good.