serverspec/specinfra — pull request #242 by mizzy (2014-10-07 08:15:31+00:00)
Title: [EXPERIMENTAL] Add function to get ec2 metadata to inventory helper

You can get ec2 metadata like this.

```ruby
pp host_inventory[:ec2]

{"ami-id"=>"ami-29dc9228",
"ami-launch-index"=>"0",
"ami-manifest-path"=>"(unknown)",
"block-device-mapping"=>{"ami"=>"/dev/xvda", "root"=>"/dev/xvda"},
"hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"instance-action"=>"none",
"instance-id"=>"i-fdcea4e4",
"instance-type"=>"t2.micro",
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"metrics"=>{"vhostmd"=>""},
"network"=>
{"interfaces"=>
{"macs"=>
{"06:9f:24:59:0d:08"=>
{"device-number"=>"0",
"interface-id"=>"eni-10830467",
"ipv4-associations"=>{"54.64.124.181"=>"172.30.1.248"},
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4s"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"owner-id"=>"853708250916",
"public-hostname"=>"",
"public-ipv4s"=>"54.64.124.181",
"security-group-ids"=>"sg-597bbc3c",
"security-groups"=>"launch-wizard-3",
"subnet-id"=>"subnet-6654bd11",
"subnet-ipv4-cidr-block"=>"172.30.1.0/24",
"vpc-id"=>"vpc-3108e254",
"vpc-ipv4-cidr-block"=>"172.30.0.0/16"}}}},
"placement"=>{"availability-zone"=>"ap-northeast-1b"},
"profile"=>"default-hvm",
"public-hostname"=>"",
"public-ipv4"=>"54.64.124.181",
"public-keys"=>
{"0"=>
{"openssh-key"=>
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCBgoqZg320DAgdessGJXTadkkQ9HHd552na9nERPiOU36WU1DE83CHDrCi7rToPLji0M+l1Vi8yXUrqPkTeC2AY7HpbG2aY+7ReLtsZin+gB2+oEMk3UGQP29foG3AB6syy7n9lm71qz9q91tItaBMszVNH7oRC1a7ZB8eJx6hNAid8uD8zsvmldOLZ+rCWTRBJLbjEm3AYTFfduL/1wptA+/7u7CJ8rRCxg4Dfwja0APTZeyjL31w3AraGTlQL0IxxTjogVb1AoGbpWC8RjUfV/IAGJGntpIJF1J+tayDSCIpvic9oi9DqGmijZpnwisdVCn88o9yL9vJ7Wpj4iDt miya\n"}},
"reservation-id"=>"r-66490760",
"security-groups"=>"launch-wizard-3",
"services"=>{"domain"=>"amazonaws.com"}}
{"ami-id"=>"ami-29dc9228",
"ami-launch-index"=>"0",
"ami-manifest-path"=>"(unknown)",
"block-device-mapping"=>{"ami"=>"/dev/xvda", "root"=>"/dev/xvda"},
"hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"instance-action"=>"none",
"instance-id"=>"i-fdcea4e4",
"instance-type"=>"t2.micro",
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"metrics"=>{"vhostmd"=>""},
"network"=>
{"interfaces"=>
{"macs"=>
{"06:9f:24:59:0d:08"=>
{"device-number"=>"0",
"interface-id"=>"eni-10830467",
"ipv4-associations"=>{"54.64.124.181"=>"172.30.1.248"},
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4s"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"owner-id"=>"853708250916",
"public-hostname"=>"",
"public-ipv4s"=>"54.64.124.181",
"security-group-ids"=>"sg-597bbc3c",
"security-groups"=>"launch-wizard-3",
"subnet-id"=>"subnet-6654bd11",
"subnet-ipv4-cidr-block"=>"172.30.1.0/24",
"vpc-id"=>"vpc-3108e254",
"vpc-ipv4-cidr-block"=>"172.30.0.0/16"}}}},
"placement"=>{"availability-zone"=>"ap-northeast-1b"},
"profile"=>"default-hvm",
"public-hostname"=>"",
"public-ipv4"=>"54.64.124.181",
"public-keys"=>
{"0"=>
{"openssh-key"=>
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCBgoqZg320DAgdessGJXTadkkQ9HHd552na9nERPiOU36WU1DE83CHDrCi7rToPLji0M+l1Vi8yXUrqPkTeC2AY7HpbG2aY+7ReLtsZin+gB2+oEMk3UGQP29foG3AB6syy7n9lm71qz9q91tItaBMszVNH7oRC1a7ZB8eJx6hNAid8uD8zsvmldOLZ+rCWTRBJLbjEm3AYTFfduL/1wptA+/7u7CJ8rRCxg4Dfwja0APTZeyjL31w3AraGTlQL0IxxTjogVb1AoGbpWC8RjUfV/IAGJGntpIJF1J+tayDSCIpvic9oi9DqGmijZpnwisdVCn88o9yL9vJ7Wpj4iDt miya\n"}},
"reservation-id"=>"r-66490760",
"security-groups"=>"launch-wizard-3",
"services"=>{"domain"=>"amazonaws.com"}}
{"ami-id"=>"ami-29dc9228",
"ami-launch-index"=>"0",
"ami-manifest-path"=>"(unknown)",
"block-device-mapping"=>{"ami"=>"/dev/xvda", "root"=>"/dev/xvda"},
"hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"instance-action"=>"none",
"instance-id"=>"i-fdcea4e4",
"instance-type"=>"t2.micro",
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"metrics"=>{"vhostmd"=>""},
"network"=>
{"interfaces"=>
{"macs"=>
{"06:9f:24:59:0d:08"=>
{"device-number"=>"0",
"interface-id"=>"eni-10830467",
"ipv4-associations"=>{"54.64.124.181"=>"172.30.1.248"},
"local-hostname"=>"ip-172-30-1-248.ap-northeast-1.compute.internal",
"local-ipv4s"=>"172.30.1.248",
"mac"=>"06:9f:24:59:0d:08",
"owner-id"=>"853708250916",
"public-hostname"=>"",
"public-ipv4s"=>"54.64.124.181",
"security-group-ids"=>"sg-597bbc3c",
"security-groups"=>"launch-wizard-3",
"subnet-id"=>"subnet-6654bd11",
"subnet-ipv4-cidr-block"=>"172.30.1.0/24",
"vpc-id"=>"vpc-3108e254",
"vpc-ipv4-cidr-block"=>"172.30.0.0/16"}}}},
"placement"=>{"availability-zone"=>"ap-northeast-1b"},
"profile"=>"default-hvm",
"public-hostname"=>"",
"public-ipv4"=>"54.64.124.181",
"public-keys"=>
{"0"=>
{"openssh-key"=>
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCBgoqZg320DAgdessGJXTadkkQ9HHd552na9nERPiOU36WU1DE83CHDrCi7rToPLji0M+l1Vi8yXUrqPkTeC2AY7HpbG2aY+7ReLtsZin+gB2+oEMk3UGQP29foG3AB6syy7n9lm71qz9q91tItaBMszVNH7oRC1a7ZB8eJx6hNAid8uD8zsvmldOLZ+rCWTRBJLbjEm3AYTFfduL/1wptA+/7u7CJ8rRCxg4Dfwja0APTZeyjL31w3AraGTlQL0IxxTjogVb1AoGbpWC8RjUfV/IAGJGntpIJF1J+tayDSCIpvic9oi9DqGmijZpnwisdVCn88o9yL9vJ7Wpj4iDt miya\n"}},
"reservation-id"=>"r-66490760",
"security-groups"=>"launch-wizard-3",
"services"=>{"domain"=>"amazonaws.com"}}
```