Have you considered using Chef Environments instead?
Something along the following lines.
#
# chef/environments/devel.rb
#
name 'devel'
description 'Development Environment'
default_attributes(
'operations' => {
'tomcat_instances' => {
:dev => {
:port => '80',
:sites => %w[Dev]
}
}
}
)
#
# chef/environments/qa.rb
#
name 'qa'
description 'QA Environment'
default_attributes(
'operations' => {
'tomcat_instances' => {
:QA => {
:port => '80',
:sites => %w[Master Staging]
}
}
}
)
I would urge you to take a look at the following link that tries to
clarify the definitions of - library, application, wrapper and base
cookbook patterns.
http://blog.vialstudios.com/the-environment-cookbook-pattern/
Chef attribute precedence and cookbook patterns are tied at the hip,
so please develop the intuition on how they are related.
Also don't confuse environment cookbook pattern to Chef
environments. They are very different ideas unfortunately named with
similar terminology.
The best way to think of environment cookbook is as an entry point into
your Chef Run. It provides something equivalent to what int main() { ... }
function does in a C program.
Best,
Rajiv
On Thu, Jun 12, 2014 at 9:15 AM, David A. Williams dwilliams@daxko.com wrote:
Hello,
Chef 11.2.4
I'm setting up a wrapper cookbook to overwrite some node attributes. However it appears when that attribute is a hash it runs both configs. Has anyone experienced this?
For example in my base cookbook, I have
attributes/default.rb
default['operations']['tomcat_instances'] = {:Dev => { :port => '80', :sites => %w[Dev] }}
And in my wrapper cookbook, I have
recipes/raven_server.rb
node.set['operations']['tomcat_instances'] = {:QA=> { :port => '80', :sites => %w[Master Staging] }}
After the chef run. I have two Tomcat instances set up instead of just one.
Thanks for your help,
David Williams
CONFIDENTIALITY NOTICE: This electronic mail may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic mail or its contents by persons other than the intended recipient(s) is strictly prohibited. If you have received this communication in error, please notify the sender immediately by reply e-mail so that we may correct our internal records. Please then delete the original message. Thank you.