[chef] Re: how to assign public definitions for custom and community cookbooks


Chronological Thread 
  • From: Matthew Moretti < >
  • To:
  • Subject: [chef] Re: how to assign public definitions for custom and community cookbooks
  • Date: Wed, 15 May 2013 12:24:43 -0400

Hey Vladimir,

You should check out the documentation on attributes.

Essentially, all of the places you suggested are possible choices - everything has precedence over default attributes in attribute files.  If you're using a "wrapper cookbook", you could use normal attributes in an attribute file of that cookbook, or use the node.default or node.normal methods in the recipe itself.

You can set default or override attributes in a role (although many would discourage it)

Or, you can set default or override attributes in environments.  Which might be good if the attribute in question is in fact dependent on which environment you're in.

Using data bags is also possible, but you'll have to write something in your cookbook to read the attributes from your databag and set your attributes.

Needless to say, there are a lot of different ways to set attributes.  To cut down on confusion, I suggest you pick one or two "right" ways to do it for your organization and stick with that.


Matt Moretti



On Wed, May 15, 2013 at 5:10 AM, Vladimir Skubriev < " target="_blank"> > wrote:
How to assign public definitions for custom and community cookbooks?

We want to use custom cookbooks and community cookbooks.

In community cookbooks there are default attributes.

For example cookbook openldap have an attribute:

default['openldap']['server'] = "ldap.localdomain"


This attribute must have our specific a domainname when chef-client runs

For example we have a custom cookbook network-basic. And this cookbook have attrribute:

default['dns']['domainname'] = "example.com"

I want to define attribute once.

Where i must define domainname:

1. in the databag for example:

    databag globalsettings item dns

knife data bag show globalsettings dns
dchostname:   pdc
dcipaddress:  192.168.0.3
domainname:   example.com
id:           dns
  
how can i override attribute from community cookbook ?
how can i define and/or override attribute dnsdomainname in a custom cookbook?

2. in the environment production for example ?

3. in the role attributes ?


-- 
Best regards,

CVision Lab System Administrator
Vladmir Skubriev




Archive powered by MHonArc 2.6.16.

§