Thanks for the quick reply Noah. Unfortunately I don’t have a solid answer to your question. I am working within an infrastructure that I did not create. I am not sure what information that I can share with you beyond the below that you might find helpful.
As far as access to other instances information; we have collections of instances organized into projects. Each project contains a bunch of attributes from all of its instances, so that any instance can see them.
As far as the data not being stored correctly, would that still be a concern, given that manually calling the attribute works as expected when call like this:
but fails when using the a var in place of the actual hostname:
?
Thanks,
Dan-Joe Lopez
Sent from Windows Mail
From:
" target="_parent">Noah
Kantrowitz
Sent: Monday, July 6, 2015 5:03 PM To: " target="_parent"> On Jul 6, 2015, at 4:53 PM, Dan-Joe Lopez < > wrote: > OHAI Chefs! > > I don’t know if this is even possible, but I am starting to feel like it is not ☹ Also, I am pretty green, so my advanced apologies if this is a silly question. > > I would like to call a specific attribute by using a variable, or another attribute. I cannot find any documentation on the subject, and every method that I have tried has resulted in an error. > > So, I can call node[‘hostname’] and get the hostname; not a problem. > But then let’s say I want to write something that calls an attribute in which the host name is one of the path components… e.g. > node[‘ec2’][‘instances’][HOSTNAME][‘ip’]… > > if I manually type in the host name, no problem: > node[‘ec2’][‘instances’][‘myhappyhost’][‘ip’] > BOOM: 12.34.56.78 > > but when I try any variation of: > node[‘ec2’][‘instances’][node[‘hostname’]][‘ip’] > or > var = node[‘hostname’] > node[‘ec2’][‘instances’][var][‘ip’] > node[‘ec2’][‘instances’][“var”][‘ip’] > node[‘ec2’][‘instances’][‘var’][‘ip’] > node[‘ec2’][‘instances’].var[‘ip’] > etc… > > nothing but errors ☹ > > Am I missing a permutation of syntax here? Is there documentation that would have given me the answer? Is this even possible? > > Your suggestions and help are appreciated! node['ec2']['instances'][var] is correct, however chances are you are not storing things correctly. How are you populating that node['ec2']['instances'] hash? Nodes cannot see the node attributes of other nodes by default, you need to use the search API or something else to get that data. --Noah |
Archive powered by MHonArc 2.6.16.