What are use cases for using "normal" attributes?

What kinds of use cases are there for using “normal” attributes, as opposed to “default”?

My understanding is that if we set an attribute at the “normal” level, the value will get persisted to the Chef Server between Chef runs, and any future attempts to change it at the “default” level will have no affect. If we ever want to change the value of that attribute, some admin would need to go in and clear the “normal” value manually from all nodes – or write a cookbook that sets it at the “override” level. It just seems like an unnecessary arms race to me if we can accomplish what we need with a “default” attribute.

I could not find much on this question in the About Attributes doc, or any recent discussion on this issue elsewhere (via Googling). I did find the following, but it’s from 2014. Does anyone have a pointer to a more recent and full discussion of the pros, cons, and use cases for using “normal” attributes?

The answer there is still correct. In general, there’s two useful properties:

  • normal attributes can be set specifically on one single node instead of via role/cookbook/etc.
  • normal attributes persist across runs

From a design perspective, I’d prefer that normal attributes not be attributes at all but be accessed via a separate API. That would be a hugely disruptive change for a lot of folks, which is why it hasn’t been done.

Anyway, you can use normal attributes if you have state you create on the system that you need to persist, or if you have a “snowflake” system that’s differs by just that one attribute, like if you start some kind of consensus system where one of the members of the cluster needs to be the initial master and create the database for the others to replicate.

It’s also possible to make a role/cookbook/etc. that just goes in the run list of the “snowflake” so everything happens more in-band, which I think is preferable if you don’t mind the slightly higher initial effort.

tl;dr, sometimes you need these behaviors but if you can get away without “normal” attributes you’ll be better off.

1 Like

Excellent, thank you very much, @kallistec. I appreciate your prompt and informative answer.