Taken from NEWS.Debian:
[mirror/dsa-puppet.git] / facts / services.rb
1 ["bugs","qa"].each do |service|
2         Facter.add(service + "_host") do
3                 confine :kernel => :linux
4                 service_name = "#{service}." + Facter.domain
5                 active = false
6
7                 setcode do
8                         if FileTest.exist?("/usr/bin/dig")
9                                 %x{/usr/bin/dig +short -t a #{service_name}}.chomp.each do |service_ip|
10                                         Facter.interfaces.split(',').each do |my_interface|
11                                                 my_ip = Facter.value("ipaddress_" + my_interface)
12                                                 if my_ip == service_ip
13                                                         active = "true"
14                                                 end
15                                         end
16                                 end
17                         end
18                         active
19                 end
20         end
21 end