summaryrefslogtreecommitdiff
path: root/lib/facter/strongswan_ips.rb
blob: 4382d07c432667e2b08b317a44311ade572f6020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
Facter.add("strongswan_ips") do
  setcode do
    bin = ['/usr/sbin/ipsec', '/usr/sbin/strongswan'].find do |f|
      File.exists?(f)
    end
    if 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
end