A strawman to fix platform dependencies


#1

If you weren’t following the CHEF-2988 thread earlier, there was mention of using a patch for allowed_recipes and restricted_recipes to help solve the platform dependency situation in chef. I’ve been building some stuff for windows, and I dislike adding depends “windows” to the mysql cookbook as much as anyone.

I think the ideal solution is to allow cookbooks to depend on resources, and select the cookbook with the appropriate provider based on platform support, environment constraints, &c.

Anyone else had this idea? Anyone have any thoughts on why it’s a bad idea?

http://josephholsten.com


#2

He Joseph,

On 21 March 2012 22:06, Joseph Holsten joseph@josephholsten.com wrote:

If you weren’t following the CHEF-2988 thread earlier, there was mention
of using a patch for allowed_recipes and restricted_recipes to help solve
the platform dependency situation in chef. I’ve been building some stuff
for windows, and I dislike adding depends “windows” to the mysql cookbook
as much as anyone.

I think the ideal solution is to allow cookbooks to depend on resources,
and select the cookbook with the appropriate provider based on platform
support, environment constraints, &c.

Anyone else had this idea? Anyone have any thoughts on why it’s a bad idea?

While the ticket you mention doesn’t clearly mention the problem it tries
to solve, I can neither see it linked to the platform dependency problem
you refer to.

For the amount of cooking time I have spent so far, I did bump into issues
where platform specific cookbook dependencies would help simplifying the
implementation of some cookbooks. While cookbooks have file-specificity, a
multi platform cookbook implementation could end up having a lot of case
statements. I think “recipe-specificity” would also help here in having a
clear cookbook implementation per platform, with some form of referring to
the common parts in the parent platform.

With platform specific dependencies and recipe specificity, the run-time on
a specific node could be optimal again without the proposed solution from
the ticket.

My $.02. :slight_smile:

Ringo


#3

On Mar 22, 2012, at 7:59 AM, Ringo De Smet ringo.desmet@gmail.com wrote:

He Joseph,

On 21 March 2012 22:06, Joseph Holsten joseph@josephholsten.com wrote:
I think the ideal solution is to allow cookbooks to depend on resources, and select the cookbook with the appropriate provider based on platform support, environment constraints, &c.

I think “recipe-specificity” would also help here in having a clear cookbook implementation per platform, with some form of referring to the common parts in the parent platform.

Are you saying cookbooks should support a structure like this:

mysql/
cookbooks/
default.rb
ubuntu/
default.rb
windows/
default.rb

My first thought is that it would lead to a lot of repetition, but you could probably handle that with judicious use of definitions, libraries and lwrps.

My main objection is that my coworkers regularly get confused by that structure in files and templates. Beyond that, we’ve gotten to a ridiculous point in some recipes, saying:

case platform
when ‘redhat’, ‘centos’, ‘scientific’, ‘oracle’, ‘fedora’, ‘amazon’

I’d hate to see that reflected in file structure.


http://josephholsten.com


#4

]] Joseph Holsten

case platform
when ‘redhat’, ‘centos’, ‘scientific’, ‘oracle’, ‘fedora’, ‘amazon’

I’d hate to see that reflected in file structure.

Why? symlinks should be your friend.

(relatedly, I’d like to have file specificity along other variables than
platform, so you can have templates/kernel/machine=x86_64 (or some
variation thereof) which will then be applied for all machines with
uname -m = x86_64. An exception will be raised if multiple templates
match, or you have a way to specify the dimension in the recipe.)


Tollef Fog Heen
UNIX is user friendly, it’s just picky about who its friends are