[chef] Ohai Custom plugin for VPC.


Chronological Thread 
  • From: Douglas Garstang < >
  • To:
  • Subject: [chef] Ohai Custom plugin for VPC.
  • Date: Thu, 29 Jan 2015 13:09:55 -0800

I was trying to write an ohai plugin to add an attribute that tells me if I'm in a VPC or not. Not really sure what I'm doing. This code works on a real VPC instance, but on vagrant it's not even setting is_vpc. :(

require 'json'

Ohai.plugin(:EC2VPC) do
  provides "is_vpc"

  collect_data do
    isa_vpc = false
    if ec2.is_a?(Hash)
        if ec2.has_key?('network_interfaces_macs')
            ec2['network_interfaces_macs'].each_pair do |iface, data|
                if data.key?('vpc_id')
                    isa_vpc = true
                end
            end
        end
    end
  is_vpc isa_vpc
  end
end


Doug.




Archive powered by MHonArc 2.6.16.

§