Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

aws: removed own ec2 facts, as recent facter versions include needed …

…fix.
  • Loading branch information...
commit 822c00434e8ee511e786f88fed5d5b16d72cfae1 1 parent 2389a0c
Marc Fournier mfournier authored

Showing 1 changed file with 0 additions and 35 deletions. Show diff stats Hide diff stats

  1. +0 35 lib/facter/ec2-metadata.rb
35 lib/facter/ec2-metadata.rb
... ... @@ -1,35 +0,0 @@
1   -# Copyright 2008 Tim Dysinger
2   -# Distributed under the same license as Facter
3   -# 27.02.09 KurtBe
4   -# Added a can_connect? function so that this fact can safely be distributed to non-ec2 instances
5   -# otherwise the script hangs if the amazon-ip is not reachable
6   -# 13.03.09 Francois Deppierraz
7   -# Fixed the timeout handling code because which was not actually working. A
8   -# file named "169.254.169.254" was created instead.
9   -
10   -require 'open-uri'
11   -require 'timeout'
12   -
13   -def metadata(id = "")
14   - open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read.
15   - split("\n").each do |o|
16   - key = "#{id}#{o.gsub(/\=.*$/, '/')}"
17   - if key[-1..-1] != '/'
18   - value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read.
19   - split("\n")
20   - value = value.size>1 ? value : value.first
21   - symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym
22   - Facter.add(symbol) { setcode { value } }
23   - else
24   - metadata(key)
25   - end
26   - end
27   -end
28   -
29   -begin
30   - Timeout::timeout(1) { metadata }
31   -rescue Timeout::Error
32   - puts "ec2-metadata not loaded - timeout"
33   -rescue Errno::ENETUNREACH
34   - puts "ec2-metadata not loaded - network unreachable"
35   -end

0 comments on commit 822c004

Please sign in to comment.
Something went wrong with that request. Please try again.