Thursday, 5 September 2013

OpsWorks Config Data: TypeError - Symbol as array index

OpsWorks Config Data: TypeError - Symbol as array index

I'm trying to use the IP of an instance on AWS OpsWorks in a Chef recipe,
code looks like this:
variables(
:db_host => (node[:scraper][:db_host] rescue nil),
:db_user => (node[:scraper][:db_user] rescue nil),
:db_pass => (node[:scraper][:db_pass] rescue nil),
:db_name => (node[:scraper][:db_name] rescue nil),
:beanstalk_host =>
(node[:opsworks][:layers][:admin][:instances].first[:private_ip])
)
But I get a TypeError - Symbol as array index error.
I'm not a Ruby developer, so I'm a bit lost with what to try. Even the
docs list that syntax:
The following example obtains the private IP address of the HAProxy
layer's first instance:
node[:opsworks][:layers][:lb][:instances].first[:private_ip]
When I log the value of node[:opsworks][:layers][:admin][:instances].first
I get:
["admin1", {"elastic_ip"=>"54.221.245....

No comments:

Post a Comment