0

In my environment file, I have defined an attribute say

['app']['web'] = 'nginx'

and in another environment file

['app']['web'] = 'apache'

My intention is to create a recipe which will run on any environment. Inside the recipe I'm defining one attribute. So while running this recipe in the first environment I want to define node.default['cluster']['nginx']['endpoint'] and in second environment it should be node.default['cluster']['apache']['endpoint']

I used the following

node.default['cluster'][node['app']['web']]['endpoint']

But this is not working. Is there any way I can achieve this ?

Jyothish
  • 1,031
  • 1
  • 9
  • 19
  • The above code will work. Actually I made a spelling mistake in the node.default['cluster'][node['app']['web']]['endpoint'] and that's the reason chef-client was failed. – Jyothish Dec 13 '18 at 06:54

2 Answers2

0

it is hard to give you a concrete answer since you did not specify the attribute type. the attribute type in conjunction with the attribute precedence will determine whether node['app']['web'] holds non nil value at the chef-client compilation phase

Mr.
  • 9,429
  • 13
  • 58
  • 82
  • I added it as default attribute in environment file. "default_attributes": { "app": { "web": "nginx" } – Jyothish Dec 06 '18 at 07:55
0

See https://github.com/poise/poise-derived for a solution. More characters because I have to.

coderanger
  • 52,400
  • 4
  • 52
  • 75