Opscode Developer John Keiser mentioned that a feature for Chef Zero he’s been working on, “local mode,” is now in Chef’s master branch. This means it should be in the next release (11.8). I took the liberty to check this unreleased feature out.
Let’s just say, it’s super awesome and John has done some amazing work here.
This is a preview of an unreleased feature in Chef. All standard disclaimers apply :).
This is in the master branch of Chef, not released as a gem yet. You’ll need to get the source and build a gem locally. This totally assumes you’ve installed a sane ruby and bundler on your system.
1 2 3 4 5
Next, point it at a local repository. I’ll use a simple example.
1 2 3 4
I created a fairly trivial example recipe to show that this will support search, and data bag items:
1 2 3 4 5 6 7 8 9 10
This simply searches for all nodes, and uses the content of the first node (the one we’re running on presumably) for a file in /tmp. It also loads a data bag item (which I created) and uses it for the content of another file in /tmp.
The data bag item:
1 2 3 4
Now, converge the node:
--local-mode argument is the magic that sets up Chef
Zero, and loads all the contents of the repository. The
tells Chef to use a one time run list of the “zero” recipe.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
The diff output from each of the file resources shows that the content does in fact come from the search (a node object was returned) and a data bag item (a data bag item object was returned).
Since this is a feature of Chef, it will be documented and released, so look for that in the next version of Chef.
I can see this used for testing purposes, especially for recipes that make use of combinations of data bags and search, such as Opscode’s nagios cookbook.
- Does it work with Berkshelf?
I don’t know. Probably not (yet).
- Does it work with Test Kitchen?
I don’t know. Probalby not (yet). Provisioners in test-kitchen would need to be (re)written.
- Should I use this in production?
This is an unreleased feature in the master branch. What do you think? :)
- When will this be released?
I don’t know the schedule for 11.8.0. Soon?
- Where do I find out more, or get involved?
Join #chef-hacking in irc.freenode.net, the chef-dev mailing list, or attend the Chef Community Summit (November 12-13, 2013 in Seattle).