Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created July 6, 2009 13:31
Show Gist options
  • Save sheldonh/141426 to your computer and use it in GitHub Desktop.
Save sheldonh/141426 to your computer and use it in GitHub Desktop.
require 'facter'
def hos_server(host, attr)
value = nil
server_block = nil
File.open("/etc/hos_server").each do |line|
line.chomp!
if line =~ /^server:\s+(\S+)\s+\{\s*$/
if host == $1
server_block = host
else
server_block = nil
end
elsif host == server_block and line =~ /^\s*([^:]+):\s*([.*]);\s*$/
if attr == $1
value = $2
break
end
end
end
value
end
Facter.add("hos_antivirus") do
setcode do
hos_server($fqdn, "antivirus")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment