As I indicated on Twitter earlier tonight, I’m working with the new Policyfile feature of ChefDK. While converting my personal systems’ repository to use Policyfile instead of roles, I found myself writing this Policyfile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
No big deal, but I found the repetition… redundant. Several of these cookbooks are fine floating on the latest version from Supermarket – everything but packages
and users
. So I thought, “wouldn’t it be great if entries in the run list were automatically added as dependencies?”
Then, I added chef-client-runit
to the run list, but I didn’t add it as a cookbook
entry, performed the chef update
, and reran my chef provision
command, and wound up with chef-client-runit
being converged.
To illustrate this with a really simple example, I confirmed with zsh
:
% cd ~/Development/sandbox/test
% chef generate policyfile
Then edit the Policyfile.rb
:
1 2 3 |
|
Note that there is no cookbook
line here.
% chef install
Building policy example_application
Expanded run list: recipe[zsh]
Caching Cookbooks...
Using zsh 1.0.1
Lockfile written to /Users/jtimberman/Development/sandbox/test/Policyfile.lock.json
And if we examine the Policyfile.lock.json
, we see:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Yay! Shoutout to Dan DeLeo for preemptively implementing features I didn’t even know I wanted yet :–).