summaryrefslogtreecommitdiff
path: root/lib/facter/strongswan_ips.rb
blob: 8875309a209e38ee059101c3a0025d2ee8e6922a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
Facter.add("strongswan_ips") do
  setcode do
    bin = ['/usr/sbin/ipsec', '/usr/sbin/strongswan'].find do |f|
      File.exists?(f)
    end
    break unless bin
    output = Facter::Util::Resolution.exec(
        "#{bin} statusall | grep -E '^  [0-9a-f]' | sort | uniq")
    output = output.to_s.split("\n").collect(&:strip)
    output.join(',') unless output.empty?
  end
end