2
votes

I am using Chef for my production environment. I am aware of the standard attribute precedence that Chef has implemented, defined here:

http://docs.chef.io/attributes.html#attribute-precedence

The default attribute presedence is as follows:

Attribute files -> Node / Recipe -> Environment -> Roles

But what happens when I have a run_list containing multiple roles? Example:

"run_list": [ "role[webserver]", "role[dbserver]" ]

Which of the above default_attributes (defined in both roles) has precedence over the other?

Thanks!

1
It will be the last role to be evaluated. I don't have a citation for that, but that's just been my experience. Attributes defined in different files but at the same precedence level will be just evaluated in order, with the last one defined being the winner. - Martin
Not 100% sure, but pretty confident that roles are applied in the order they appear in the runlist. As Martin said, the last one will win regarding precedence. The other possibility that comes to mind is that they may be applied lexicographically, but I don't think that's the case. - Tejay Cardon

1 Answers

1
votes

This depends on how your attribute structures are defined in your roles. http://docs.chef.io/attributes.html#about-deep-merge