From 3a44434a6846baf551cba5ed890d7c9c482dc9fb Mon Sep 17 00:00:00 2001 From: o Date: Sat, 10 Aug 2013 19:08:40 +0200 Subject: avoid collecting duplicate ips in the facts --- lib/facter/strongswan_ips.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/facter/strongswan_ips.rb b/lib/facter/strongswan_ips.rb index 7fac37e..3cb2f69 100644 --- a/lib/facter/strongswan_ips.rb +++ b/lib/facter/strongswan_ips.rb @@ -1,10 +1,12 @@ 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 - result + 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 -- cgit v1.2.3