Created
July 6, 2009 13:31
-
-
Save sheldonh/141426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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