Recipe subset-ing

Hello,

I have cookbook X that calls many functions off of cookbook Y. But my
attributes for cookbook X are a superset of cookbook Y’s attributes and of
the values that intersect some are different in cookbook X.

How would I go about doing this correctly?

Right now I call include_recipe “Y::recipe1” from “X::default”, but it seems
to overwrite all my X configs that intersect.

Should I just change cookbook X to use override instead of default settings?

Thanks for the help!
Joaquin

On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:

Hello,
I have cookbook X that calls many functions off of cookbook Y. But my attributes for cookbook X are a superset of cookbook Y's attributes and of the values that intersect some are different in cookbook X.
How would I go about doing this correctly?
Right now I call include_recipe "Y::recipe1" from "X::default", but it seems to overwrite all my X configs that intersect.
Should I just change cookbook X to use override instead of default settings?
Thanks for the help!
Joaquin
If possible, you should structure your recipes and roles to avoid this situation entirely. If that's not an option, you can use include_attribute in an attributes file to force one attributes file to load before another.

--
Dan DeLeo

If you're combined set of code involves mostly collating multiple recipes
from different cookbooks, you can just create a role, and provide override
attributes in it:
http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes

given the precedence order (
http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence) that
might just do the trick.

On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo dan@kallistec.com wrote:

On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:

Hello,
I have cookbook X that calls many functions off of cookbook Y. But my
attributes for cookbook X are a superset of cookbook Y's attributes and of
the values that intersect some are different in cookbook X.
How would I go about doing this correctly?
Right now I call include_recipe "Y::recipe1" from "X::default", but it
seems to overwrite all my X configs that intersect.
Should I just change cookbook X to use override instead of default
settings?
Thanks for the help!
Joaquin
If possible, you should structure your recipes and roles to avoid this
situation entirely. If that's not an option, you can use include_attribute
in an attributes file to force one attributes file to load before another.

--
Dan DeLeo

I went ahead and went with the precendence ordering.

I couldn't do the 'include_attribute' since the first script I ran need the
X's attributes already, and it seemed like it would load Y's attributes as
soon as it ran.

The idea of roles are great, but I really like being able to git control my
attributes file which I can't do natively with the roles.

Thanks a lot for the suggestions though! I'll definitely keep them in mind
as I work with Chef further.

Joaquin Casares
DataStax
Software Engineer/Support

On Thu, Aug 11, 2011 at 11:07 AM, andi abes andi.abes@gmail.com wrote:

If you're combined set of code involves mostly collating multiple recipes
from different cookbooks, you can just create a role, and provide override
attributes in it:
http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes

given the precedence order (
http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence)
that might just do the trick.

On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo dan@kallistec.com wrote:

On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:

Hello,
I have cookbook X that calls many functions off of cookbook Y. But my
attributes for cookbook X are a superset of cookbook Y's attributes and of
the values that intersect some are different in cookbook X.
How would I go about doing this correctly?
Right now I call include_recipe "Y::recipe1" from "X::default", but it
seems to overwrite all my X configs that intersect.
Should I just change cookbook X to use override instead of default
settings?
Thanks for the help!
Joaquin
If possible, you should structure your recipes and roles to avoid this
situation entirely. If that's not an option, you can use include_attribute
in an attributes file to force one attributes file to load before another.

--
Dan DeLeo

hmmm. why can't you control attributes in a role using git? Can't you save
the role into a file and manipulate using knife?

On Thu, Aug 11, 2011 at 5:46 PM, Joaquin Casares joaquin@datastax.comwrote:

I went ahead and went with the precendence ordering.

I couldn't do the 'include_attribute' since the first script I ran need the
X's attributes already, and it seemed like it would load Y's attributes as
soon as it ran.

The idea of roles are great, but I really like being able to git control my
attributes file which I can't do natively with the roles.

Thanks a lot for the suggestions though! I'll definitely keep them in mind
as I work with Chef further.

Joaquin Casares
DataStax
Software Engineer/Support

On Thu, Aug 11, 2011 at 11:07 AM, andi abes andi.abes@gmail.com wrote:

If you're combined set of code involves mostly collating multiple recipes
from different cookbooks, you can just create a role, and provide override
attributes in it:
http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes

given the precedence order (
http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence)
that might just do the trick.

On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo dan@kallistec.com wrote:

On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:

Hello,
I have cookbook X that calls many functions off of cookbook Y. But my
attributes for cookbook X are a superset of cookbook Y's attributes and of
the values that intersect some are different in cookbook X.
How would I go about doing this correctly?
Right now I call include_recipe "Y::recipe1" from "X::default", but it
seems to overwrite all my X configs that intersect.
Should I just change cookbook X to use override instead of default
settings?
Thanks for the help!
Joaquin
If possible, you should structure your recipes and roles to avoid this
situation entirely. If that's not an option, you can use include_attribute
in an attributes file to force one attributes file to load before another.

--
Dan DeLeo