summaryrefslogtreecommitdiff
path: root/lib/facter/strongswan_ips.rb
blob: 3cb2f699acccb50b67a51499a0826d90e15751f3 (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
    return unless bin
    output = Facter::Util::Resolution.exec(
        "#{bin} statusall | grep -E '^  [0-9a-f]' | sort | uniq")
            .to_s.split("\n").collect(&:strip)
    output.join(',') unless output.empty?
  end
end