Databags vs Attributes


#1

Hi all,

I’m a bit confused as to when I should be using databags and when I should be using attributes, as both provide data to chef server and chef clients.

I like attributes, because defaults can be defined in recipes, which get uploaded with a rake install or a knife cookbook upload
I like databags, because I can define them outside a cookbook, so it is easier to have vanilla cookbooks without changing them

But I dont really understand the real reasons as to where I should use one and not the other… Can anybody explain?

Thanks

Geoff


#2

An attribute is a per-node thing. A data bag is per Chef server (so
across nodes).
Sure, with attributes, you have interesting defaulting and overriding
mechanisms but, in the end, it ends up as a value on your node.

Databags are where you would store info that lots of nodes need to
know and share.

On Thu, Sep 15, 2011 at 8:37 AM, Geoff Meakin Acid
geoffmeakin@aciddevelopments.co.uk wrote:

Hi all,
I’m a bit confused as to when I should be using databags and when I should
be using attributes, as both provide data to chef server and chef clients.
I like attributes, because defaults can be defined in recipes, which get
uploaded with a rake install or a knife cookbook upload
I like databags, because I can define them outside a cookbook, so it is
easier to have vanilla cookbooks without changing them
But I dont really understand the real reasons as to where I should use one
and not the other… Can anybody explain?
Thanks

Geoff