Search code examples
chef-infrachef-solo

Where can I place attributes that need to be accessible from all cookbooks


Is there some place where I can put all common attributes/properties.? Maybe solo.rb?

-j json is not applicable for me.


Solution

  • The answer really depends on what kind of attribute it is.

    For example you could set a common global attribute in a:

    • Environment
    • Role
    • Cookbook included by all other cookbooks

    An exotic alternative would be to use a databag, another useful way to record global data.

    Example use-cases:

    • Store truly global information (stuff that never changes) in an Environment. This enables you to later create logically groupings of VMs with slight different global defaults.
    • For common attributes that rarely change consider a common cookbook, instead of a role. Roles cannot be versioned a feature that might be useful if you later want to support Dev/Test/Prod environments.
    • Databags are most useful when used to "data drive" a cookbook. I use them to generate resources, such as projects and other types of entity in my system.