[chef] Re: Re: Ohai Custom plugin for VPC.

Chronological Thread 
  • From: Douglas Garstang < >
  • To:
  • Subject: [chef] Re: Re: Ohai Custom plugin for VPC.
  • Date: Fri, 30 Jan 2015 11:23:50 -0800


No, but I've realised I can't use it anyway. Apparently data from custom ohai plugins is not available in the attributes.rb file. However, data from standard ohai plugins is. I don't think this is documented anywhere. I worked this out from observation. Since, at least in my case, I need to check if it's a vpc or not in the attributes file in order to set attributes used by upstream cookbooks, well, I just can't use it.


On Fri, Jan 30, 2015 at 11:21 AM, Jeff Byrnes < " target="_blank"> > wrote:

Do you have this code published anywhere? Would love to help out with it if I can, but can’t tackle it just yet.

Jeff Byrnes
Lead DevOps Engineer

On January 29, 2015 at 4:10:11 PM, Douglas Garstang ( " target="_blank"> ) wrote:

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
  is_vpc isa_vpc



Archive powered by MHonArc 2.6.16.