ec2-facts not shown when running in AWS VPC

Bug #1240054 reported by Daniel Roschka
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
facter (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

When running Facter (1.6.x or 1.7.x) from Ubuntu 12.04 LTS or 14.04 LTS on an EC2-instance inside AWS VPC, no EC2-facts are shown. This bug is already reported upstream and is a problem with the way Facter determines if the OS is running in EC2. Facter can detect EC2-Classic but can not detect EC2-VPC: http://projects.puppetlabs.com/issues/7559. This problem is fixed in Facter 2.1.0 release (https://github.com/puppetlabs/facter/releases/tag/2.1.0)

Revision history for this message
Scott Moser (smoser) wrote :

Hi,
  You reported this against 12.04. Could you please test with the development release (14.04/trusty) and see if it is fixed ? The upstream issue you've pointed to is marked as fixed. The latest upstream is 1.7.4 [1] and trusty has version has 1.7.2 [2], but It seems like even 1.7.4 might not have that fix.

Can you verify the problem still exists on trusty? It seems to me to still be broken based on running:
  $ facter | grep ec2
when inside a vpc, nothing is shown. On a non-vpc instance, there is data found.

Do you know if it is fixed in any released version of facter?

--
[1] http://puppetlabs.com/misc/download-options
[2] https://launchpad.net/ubuntu/+source/facter

Changed in facter (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Daniel Roschka (v-daniel-d) wrote :

I currently don't have the time to test it with Ubuntu 14.04, but according to the upstream bug report it's only fixed for the upcoming 2.0.0 version of facter.

Revision history for this message
Devon P. Hubner (devon-hubner) wrote :
Download full text (5.5 KiB)

This is still a problem on Ubuntu 14.04.1 with puppet 3.4.3 and facter 1.7.5.
Interestingly, on Amazon Linux 2014.09 with puppet 2.7.25 and facter 1.6.18, the EC2_* facts are present.

The latest version of the gem appears to have completely refactored the ec2.rb facts: https://github.com/puppetlabs/facter/blob/master/lib/facter/ec2.rb

The latest 1.7.x gem release is still broken: https://github.com/puppetlabs/facter/releases/tag/1.7.6d

The 1.6.18 gem has the same broken ec2 code: https://github.com/puppetlabs/facter/releases/tag/1.6.18

Looking at the amzn1 source rpm, it appears Amazon is patching the facter gem when packaging it:
https://alami-source-request.amazonaws.com/cgi-bin/source_request.cgi?instance_id=i&region=us-east-1&version=2014-09-0&srpm_name=facter-1.6.18-7.25.amzn1.src.rpm

rpm2cpio - < facter-1.6.18-7.25.amzn1.src.rpm | cpio -idmv
      0001-19989-Filter-virt-what-warnings-from-virtual-fact.patch
      0002-976942-correct-ipaddress-non-loopback.patch
      0003-ipaddress-parsing-net-tools.patch
      0004-FACT-480-Remove-current-directory-from-Ruby-load-path.patch
      facter-1.6.18-ec2-vpc.patch
      facter-1.6.18.tar.gz
      facter-1.6.18.tar.gz.asc
      facter.spec

FILE: facter-1.6.18-ec2-vpc.patch
      diff -up facter-1.6.18/lib/facter/ec2.rb.vpc facter-1.6.18/lib/facter/ec2.rb
      --- facter-1.6.18/lib/facter/ec2.rb.vpc 2013-03-13 18:17:44.000000000 +0000
      +++ facter-1.6.18/lib/facter/ec2.rb 2013-05-09 18:04:10.000000000 +0000
      @@ -28,8 +28,7 @@ def userdata()
         end
       end

      -if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_openstack_mac? ||
      - Facter::Util::EC2.has_ec2_arp?) && Facter::Util::EC2.can_connect?
      +if Facter::Util::EC2.can_connect?
         metadata
         userdata
       else
      diff -up facter-1.6.18/lib/facter/util/ec2.rb.vpc facter-1.6.18/lib/facter/util/ec2.rb
      --- facter-1.6.18/lib/facter/util/ec2.rb.vpc 2013-03-13 18:17:44.000000000 +0000
      +++ facter-1.6.18/lib/facter/util/ec2.rb 2013-05-09 18:03:26.000000000 +0000
      @@ -35,6 +35,7 @@ module Facter::Util::EC2

           # Test if the host has an arp entry in its cache that matches the EC2 arp,
           # which is normally +fe:ff:ff:ff:ff:ff+.
      + # WARNING: This does not work in VPC as VPC hosts have real MAC addresses
           def has_ec2_arp?
             kernel = Facter.value(:kernel)

## From Amazon Linux 2014.09 in VPC:
curl http://169.254.169.254/2008-02-01/meta-data/instance-id
           i-2b54b1cb

curl http://169.254.169.254/2008-02-01/meta-data/ami-id
           ami-b66ed3de

facter -d metadata
           value for lsbdistid is still nil

FILE: /usr/lib/ruby/site_ruby/1.8/facter/ec2.rb

              # Test if the host has an arp entry in its cache that matches the EC2 arp,
              # which is normally +fe:ff:ff:ff:ff:ff+.
              # WARNING: This does not work in VPC as VPC hosts have real MAC addresses
              def has_ec2_arp?
                kernel = Facter.value(:kernel)

                mac_address_re = case kernel
                                 when /Windows/i
                                   /fe...

Read more...

description: updated
Revision history for this message
Devon P. Hubner (devon-hubner) wrote :

Workaround resolution:

apt-get install -y puppet
# installs puppet dependency: facter-1.7.5-1ubuntu1

gem install facter
# installs latest facter gem, 2.3.0 where the ec2_* facts in VPC are restored

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.