BasicObject
# File lib/facter/ipaddress6.rb, line 26 def get_address_after_token(output, token, return_first=false) ip = nil String(output).scan(/#{token}\s?((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match| match = match.first unless match =~ /fe80.*/ or match == "::1" ip = match break if return_first end end ip end
# File lib/facter/ec2.rb, line 4 def metadata(id = "") open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read. split("\n").each do |o| key = "#{id}#{o.gsub(/\=.*$/, '/')}" if key[-1..-1] != '/' value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read. split("\n") symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym Facter.add(symbol) { setcode { value.join(',') } } else metadata(key) end end rescue => details Facter.warn "Could not retrieve ec2 metadata: #{details.message}" end
This supports the fact that the selinux mount point is not always in the same location – the selinux mount point is operating system specific.
# File lib/facter/selinux.rb, line 17 def selinux_mount_point path = "/selinux" if FileTest.exists?('/proc/self/mounts') # Centos 5 shows an error in which having ruby use File.read to read # /proc/self/mounts combined with the puppet agent run with --listen causes # a hang. Reading from other parts of /proc does not seem to cause this problem. # The work around is to read the file in another process. # -- andy Fri Aug 31 2012 selinux_line = Facter::Util::Resolution.exec('cat /proc/self/mounts').lines.find { |line| line =~ /selinuxfs/ } if selinux_line path = selinux_line.split[1] end end path end
Generated with the Darkfish Rdoc Generator 2.