[Bug 1240054] Re: ec2-facts not shown when running in AWS VPC
Devon P. Hubner
1240054 at bugs.launchpad.net
Thu Dec 11 16:29:30 UTC 2014
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®ion=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-ff-ff-ff-ff-ff/i
else
/fe:ff:ff:ff:ff:ff/i
end
arp_command = case kernel
when /Windows/i, /SunOS/i
"arp -a"
else
"arp -an"
end
if arp_table = Facter::Util::Resolution.exec(arp_command)
return true if arp_table.match(mac_address_re)
end
return false
end
...
...
if Facter::Util::EC2.can_connect?
metadata
userdata
else
Facter.debug "Not an EC2 host"
end
## From Ubuntu 14.04.1 in VPC:
curl http://169.254.169.254/2008-02-01/meta-data/instance-id
i-854ca965
curl http://169.254.169.254/2008-02-01/meta-data/ami-id
ami-9eaa1cf6
facter -d metadata
Not an EC2 host
FILE: /usr/lib/ruby/vendor_ruby/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-ff-ff-ff-ff-ff/i
else
/fe:ff:ff:ff:ff:ff/i
end
arp_command = case kernel
when /Windows/i, /SunOS/i
"arp -a"
else
"arp -an"
end
if arp_table = Facter::Util::Resolution.exec(arp_command)
return true if arp_table.match(mac_address_re)
end
return false
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?
metadata
userdata
else
Facter.debug "Not an EC2 host"
end
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to facter in Ubuntu.
https://bugs.launchpad.net/bugs/1240054
Title:
ec2-facts not shown when running in AWS VPC
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/facter/+bug/1240054/+subscriptions
More information about the Ubuntu-server-bugs
mailing list