chef-infracookbookohai-gem

How can Chef detect an AWS ec2 instance type?


I need to have an arbitrary script ran if an instance is run on an ENA enabled ami (eg, c5.2xlarge) A shell command easily enough validates the type:

cat /sys/class/dmi/id/product_name
c5.2xlarge

...but I'm guessing there is something in ohai that will help with this detection as well. Not sure where / how to access the attribute however. Any ideas?


Solution

  • It should be in the EC2 metadata gathered by ohai, try node['ec2']['instance-type'] or something like that (might be instance_type, run ohai ec2 from a command line to see what data it grabs).