From d3c47755850e576f3d37720a18b6e73ec0faafde Mon Sep 17 00:00:00 2001 From: Greg Batye Date: Tue, 11 Oct 2022 12:29:13 -0700 Subject: [ohai][ec2][looks_like_ec2] Do not depend on metadata endpoint (#1768) Do not depend metadata endpoint For environments where full tunnel VPN is used, requiring a connection to the local metadata endpoint causes node['cloud'] = nil. At a minimum node['cloud']['provided'] attribute should be populated even if metadata can not be fetched. Signed-off-by: Greg Batye --- lib/ohai/plugins/ec2.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 5799d838..1a7c1690 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -28,10 +28,8 @@ Ohai.plugin(:EC2) do require_relative "../mixin/ec2_metadata" - require_relative "../mixin/http_helper" include Ohai::Mixin::Ec2Metadata - include Ohai::Mixin::HttpHelper provides "ec2" @@ -107,11 +105,7 @@ Ohai.plugin(:EC2) do # @return [Boolean] Does the system appear to be on EC2 def looks_like_ec2? return true if hint?("ec2") - - # Even if it looks like EC2 try to connect first - if has_ec2_xen_uuid? || has_ec2_amazon_dmi? || has_ec2_xen_dmi? || has_ec2_identifying_number? - return true if can_socket_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80) - end + return true if has_ec2_xen_uuid? || has_ec2_amazon_dmi? || has_ec2_xen_dmi? || has_ec2_identifying_number? end collect_data do -- cgit v1.2.1