From a8a2c4473311f88784e5edac68ea4fe0074b0c90 Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Mon, 29 Jun 2009 08:03:30 +0100 Subject: [PATCH] How many of our hosts have a broken /etc/hosts ? Signed-off-by: Stephen Gran --- facts/hosts.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 facts/hosts.rb diff --git a/facts/hosts.rb b/facts/hosts.rb new file mode 100644 index 000000000..3e6b2d9dd --- /dev/null +++ b/facts/hosts.rb @@ -0,0 +1,19 @@ +Facter.add("brokenhosts") do + confine :kernel => :linux + brokenhosts = "true" + if FileTest.exist?("/etc/hosts") + IO.foreach("/etc/hosts") do |x| + x.split.each do |y| + if y == fqdn + brokenhosts = "false" + break + end + end + end + end + setcode do + brokenhosts == "true" + end +end + + -- 2.20.1