[chef] Re: Roles with same runlist, overriding same attributes - to be used on same node


Chronological Thread 
  • From: Dylan Northrup < >
  • To:
  • Subject: [chef] Re: Roles with same runlist, overriding same attributes - to be used on same node
  • Date: Fri, 24 Jan 2014 09:24:48 -0500

Uh... yeah.  Thinking about it as code

-- BEGIN CODE --
= ""
 def converge_node() {
   puts "We're doing stuff with "
   # go and do converge stuff
 }
 
= "foo"
= "bar"
 converge_node()

-- END CODE --

I would not expect to see a line saying "We're doing stuff with foo" because I'm overriding the exact same attributes with different values that my converge_role method is using.  There should not be an expectation chef-client (or my simple converge_node method) should know the history of the attribute and whatever values it might have had prior in the program run.

If you want your roles to work with multiple different attributes, you might want to look into making the attributes "arrayable", then check if they have a single value or multiple values and react appropriately.  This requires work and testing, though, and may be a somewhat complicated process to implement.



On Fri, Jan 24, 2014 at 8:25 AM, < " target="_blank"> > wrote:
Hello chefs,
We are testing our chef setup with our infrastructure and came across an
interesting situation. We have separate roles for each application, to setup
application specific files and environment. These roles have exact same runlist
and override exact same set of attributes (with different values, of course).
For testing, we assigned all the roles to one node.
Now running chef-client on the server resulted in only 1 execution of the
runlist. So we thought that it might be because runlist being resolved to same
set of recipes for all the roles. We then created different recipe for each
application and added it to the corresponding role. Now the roles consist of
different recipes but still override same set of attributes. Chef-client now
runs all the recipes but using the attribute values overridden by the *last
role assigned* to the node i.e. all the roles are executed using same attribute
values.
I have tried many different combinations but none of them lead to expected
behaviour i.e. ability to run different roles, with same runlist and overriding
same attributes, on the same node.
Any suggestions are highly appreciated.

Cheers




Archive powered by MHonArc 2.6.16.

§