New to chef, and trying to get my head around best practices.
I’m using Chef to automate the building of EC2 AMI images (from an EC2
instance). This is a bit of a special case, because I’m running chef
from within a chroot environment, so I can’t start services.
So, I can see four categories of cookbooks I need:
A. Third party cookbooks
B. My own original cookbooks to perform specific tasks (e.g.
installing required dev packages)
C. Cookbooks which perform necessary overrides to third party
cookbooks (e.g. I find a bug in the third party cookbook)
These first three categories are “normal”, and should be able to run
in the chroot environment, and also be run to update/fix EC2 images
which are created from the built AMI. However, the fourth is a
D. Cookbooks which perform overrides to third party cookbooks, in
order to prevent services from automatically
starting/stopping/restarting (which will fail in a chroot env).
Obviously, I only want to include this category when I’m building the
AMI, but not when running normally on an instance started from the
- Does anything sound wrong about this approach
- How should I organize these cookbooks? I can have a custom repo,
which includes all the third-party cookbooks (A) as submodules, and
the others (B,C,D) checked in directly. However, I would want to
conditionally exclude “D” from running if I’m not in a chroot
Seems like I want to use “Roles” here to do some conditional logic
based on whether I’m in chroot env or not, but I’m not sure what it
should look like. I’m not even really sure where to stick the logic.
Right now I just have cookbooks listed in the ‘cookbook_path’ array in
node.rb. I’m having problems finding detailed examples online which
are similar to what I want to do. Pointers to docs/examples would be