summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoro <o@immerda.ch>2013-08-10 19:08:40 +0200
committero <o@immerda.ch>2013-08-10 19:08:40 +0200
commit3a44434a6846baf551cba5ed890d7c9c482dc9fb (patch)
treec50ce0eafda772990ff8facb98ee53b13be84f10
parent9bff4b7d2222f3bba58603efde427532d3a5f502 (diff)
avoid collecting duplicate ips in the facts
-rw-r--r--lib/facter/strongswan_ips.rb12
1 files 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