summaryrefslogtreecommitdiff
path: root/lib/facter/strongswan_ips.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facter/strongswan_ips.rb')
-rw-r--r--lib/facter/strongswan_ips.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/facter/strongswan_ips.rb b/lib/facter/strongswan_ips.rb
index 7fac37e..4382d07 100644
--- a/lib/facter/strongswan_ips.rb
+++ b/lib/facter/strongswan_ips.rb
@@ -1,10 +1,13 @@
Facter.add("strongswan_ips") do
setcode do
- result = nil
- if bin = ['/usr/sbin/ipsec', '/usr/sbin/strongswan'].find{|f| File.exists?(f) }
- output = Facter::Util::Resolution.exec("#{bin} statusall | grep -E '^ [0-9a-f]'").to_s.split("\n").collect(&:strip)
- result = output.join(',') unless output.empty?
+ 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
- result
end
end