[chef] Re: Determine inside VPC


Chronological Thread 
  • From: David Petzel < >
  • To:
  • Subject: [chef] Re: Determine inside VPC
  • Date: Mon, 26 Jan 2015 14:47:07 -0500

Perhaps this will work for you?
vpc_id = nil
node['ec2']['network_interfaces_macs'].each_pair do |iface, data|
  vpc_id = data['vpc_id'] if data.key?('vpc_id')
end


On Mon, Jan 26, 2015 at 2:38 PM, Douglas Garstang < " target="_blank"> > wrote:
I'm trying to use ohai to determine if my instance is inside a VPC. There's a key nested down there under node['ec2']['network_interfaces_macs'] when this is the case, called vpc_id, but my ruby is horrible and I'm having trouble fetching it. For reasons I don't understand ohai reports this is a dictionary, but when I attempt to iterate over it inside a chef recipe, it's an array.

Is there an easy/better way to determine in chef if your ec2 instance is inside a VPC?

Doug






Archive powered by MHonArc 2.6.16.

§