Unable to Fetch JSON Values In Chef Recipe

cloudtechnician
cloudtechnician used Ask the Experts™
on
Just getting started with using chef recently.  I have created custom JSON in AWS Opswork and trying to access it as an attribute in Chef recipe, but its failing to grab the JSON values. JSON file looks like.
{
 "normal": { 
 "filbeat": {
 "log_path" : "/var/log/*.log",
 "hosts" : "Some Random Host ID", 
 "port"  : 5000
 }
 }
}

Open in new window


and I am trying to catch it in recipe as,

log = node['filebeat']['log_path']
hosts = node['filebeat']['hosts']
port = node['filebeat']['port']

Open in new window


But it failed, I have also tried without 'normal'. I got the some []null class error.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
director
Commented:
The structure suggest that the right nomenclature woudld be
log = node['normal']['filbeat']['log_path'];

Open in new window

Now either you have a typo in the posted JSON structure (filbeat instead of filebeat) or a typo in your calling values.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial