Help with attributes


#1

Hi

I’m having some issues with attributes, my values are changing at
random after each chef-client run.
Let me explain it a little more:

I have a cookbook for “tomcat”, this cookbook drops a file in
/etc/tomcat6/server.xml using a template. The attributes file of this
cookbook contains nothing relevant to this file.

I have another cookbook for one of the apps that we deploy in tomcat,
this cookbook includes the ‘tomcat’ cookbook and it has the following
set in the attributes:
default[:tomcat][:default_host] = 'dev.myapp.net
default[:tomcat][‘vhosts’][‘dev.myapp.net’][‘app’] = 'dev’
default[:tomcat][‘vhosts’][‘dev.myapp.net’][‘base’] = 'dev’
default[:tomcat][‘vhosts’][‘dev.myapp.net’][‘path’] = ‘/’

I then have another cookbook for yet another app that we deploy in
tomcat, this cookbook is similar to the above and it sets the
following in its attributes:
default[:tomcat][‘vhosts’][‘dev.otherapp.net’][‘app’] = 'otherapp’
default[:tomcat][‘vhosts’][‘dev.otherapp.net’][‘base’] = 'optherapp’
default[:tomcat][‘vhosts’][‘dev.otherapp.net’][‘path’] = ‘/’

Now on a particular environment I include both those cooks (which
ultimately call the tomcat one) and I then try override all those
settings with the following JSON in the node file:
{ “normal” : {
“tomcat” : {
“default_host” : “prod.myapp.net”,
“vhosts” : {
prod.myapp.net” : { “app” : “prod”, “base” : “prod”,
“path” : “/” }
}
}
}

In my head this should work, my server.xml file should be populated
with the stuff in the JSON as they are set as “normal” and this should
take preference over the “default” attributes.
However, after every chef-client run I get a different result.
Sometimes the file is as I expect it, other times the default_host has
changed to “dev.myapp.net”, other times I have “prod.myapp.net”,
dev.otherapp.net” and “dev.myapp.net” all in the file.

Every time I run chef-client the file changes.

Any idea what I’m doing wrong?

Thanks
Adrian