How to assign public definitions for custom and community cookbooks


#1

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?

  1. in the environment production for example ?

  2. in the role attributes ?


Best regards,

CVision Lab System Administrator
Vladmir Skubriev


#2

Hey Vladimir,

You should check out the documentation on
attributeshttp://docs.opscode.com/essentials_cookbook_attribute_files.html
.

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
skubriev@cvisionlab.comwrote:

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?

  1. in the environment production for example ?

  2. in the role attributes ?


Best regards,

CVision Lab System Administrator
Vladmir Skubriev


#3

On 15.05.2013 20:24, Matthew Moretti wrote:

Hey Vladimir,

You should check out the documentation on attributes
http://docs.opscode.com/essentials_cookbook_attribute_files.html.

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
<skubriev@cvisionlab.com mailto:skubriev@cvisionlab.com> 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 <http://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 <http://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

I choice environment way to store domain name and domain specific
attributes:

"dc": {
   "ip": "192.168.0.3",
   "hostname": "pdc"
 },
 "krb5": {
   "kadmind": "admin",
   "ldapservicepasswordfile": "/etc/krb5kdc/service.keyfile",
   "kdc": "admin",
   "ldapconnsperserver": "2"
 },
 "dns": {
   "domain": "example.com"
 },
 "ldap": {
   "base": "dc=example,dc=com",
   "admin": "admin",
   "realmuppercase": "EXAMPLE.COM"
 }

For a service users i choice data bag:

 "kadmind": {
   "name": "admin",
   "pw": "pw"
 },
 "ldap": {
   "name": "admin",
   "pw": "pw"
 },
 "kdc": {
   "name": "admin",
   "pw": "pw"
 },
 "krbmaster": {
   "name": "",
   "pw": "pw"

I reealy confused with attributes/default/default.rb file. Because this
file now is empty. And I must remeber about I store attributes in
environment and cookbook wiil retrive those vars from environment.

Maybe I must put using vars in default.rb and assign nil values to used
variables ? What is best practic ?

Or maybe I must assign my default values - are the same as in
environment? I am afraid that i forget about they are set in the spirit
of the place. And it can be confusing in future work.


Best regards,

CVision Lab System Administrator
Vladmir Skubriev