I made this comment on the blog post and haven’t had time to respond
to its reponse.
“cookbooks by default have to be opinionated”
I stand by that for this reason (with a few caveats):
- You must have defaults. You can’t lay bits out on disk without some
opinion of where they need to go
- Some things don’t make sense as configurable (I’m not going to
deploy a php app to rails and I’m I might HAVE to use a specific
version of php)
- In cases where cookbooks have interdependencies, you must be able to
express that (take the opscode users cookbook and nagios cookbook -
both want an explcitly named admin group)
Having said that, yes, folks who publish cookbooks should consider
making as much as possible as attributes. The reason here is obvious.
It’s much easier to override attributes than to override an entire
recipe. As a counter though, if the attitude is that folks have to
have a fully configurable cross-platform cookbook before they can
release it, then I don’t want that. I’d rather have an unnecessarily
opinionated cookbook than no cookbook at all. In fact, I’m working
with someone at the new company who has very little chef experience
and my advice was to hard code everything. We can refactor into
Here’s an example of a cookbook we used at my last gig where I made
some things overly configurable even though we weren’t ready for it
default[:portal][:container] = "jetty"
default[:portal][:base_dir] = "/usr/local/portal/"
default[:portal][:user] = "portal"
default[:portal][:group] = "portal"
default[:portal][:context_path] = "/portal"
default[:portal][:warfile] = “portal.war”
We were not even remotely ready to run on anything other than jetty
and the context root HAD to be portal, however I went ahead and made
them attributes just in case we ever got to the point where we weren’t
tied so heavily to jetty.
I think cookbook authors could do at least the following as attributes
since these areas are probably the most common:
(maybe) init script
use ‘conf.d’ setups where available instead of owning a file wholesale.
The main reason for not doing initscript is that it litters the
codebase with ugly-ass conditionals which actually HURT readability.
I’m considering a proposal to make init scripts more intelligent like
the runit LWRP. Yes, you can sort of do it with file specificity in
the templates directory but upstart files don’t go in the same places
as SYSV init scripts so you’ve still got some conditionals.
Also, the post is awesome and very much appreciated. I just think that
in a few areas it goes to far to the extreme. With proper attributes,
there’s no reason you need a distinct recipe JUST for group creation
(and at worst case you’ve created an ordering issue that might not be
On Mon, Mar 5, 2012 at 10:25 AM, Wes Morgan email@example.com wrote:
On Mar 5, 2012, at 9:54 AM, Nikolay Sturm wrote:
after adapting more than enough community cookbooks to our local setup,
I published a blog entry yesterday to describe my idea of improving the
status quo wrt/ reusable cookbooks:
I would love to discuss these ideas and see what people think about it.
“It’s all part of my Can’t-Do approach to life.” Wally
Here here! I couldn’t agree more with your suggestions.
In addition, I think we need better tools to manage, share, and collaborate on our cookbooks. So, for example, if I write a cookbook that’s tightly-coupled to my infrastructure and you come along and improve it along the lines you describe in your post, there should be a way for you to put your version forward to the community and then for everyone to collectively communicate that yours is the new best version and submit their own improvements, etc.
So this could be a layer on top of GitHub (and we’d need to make the knife-GitHub integration more official), or it could be a vastly-improved community.opscode.com, or something else entirely. But right now there is just too much friction between “I’ve made this cookbook more general” and “this is now the primary version of this cookbook.”