From: Stephen Gran Date: Mon, 29 Jun 2009 07:03:30 +0000 (+0100) Subject: How many of our hosts have a broken /etc/hosts ? X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=a8a2c4473311f88784e5edac68ea4fe0074b0c90;p=mirror%2Fdsa-puppet.git How many of our hosts have a broken /etc/hosts ? Signed-off-by: Stephen Gran --- 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 + +