]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Changed the fact flush call to make it compatible with Facter 4
authorAndrei Filipovici <andrei.filipovici@andreis-mbp.eth.tsr.corp.puppet.net>
Wed, 18 Mar 2020 11:25:02 +0000 (13:25 +0200)
committerAndrei Filipovici <andrei.filipovici@andreis-mbp.eth.tsr.corp.puppet.net>
Wed, 18 Mar 2020 11:25:02 +0000 (13:25 +0200)
lib/puppet/util/firewall.rb

index 676bcf82e9e41ad887b86394dbed9d98e3cffb0d..add4ac06d7413d24dd9339aeca0ea2d027d4f3dc 100644 (file)
@@ -180,8 +180,11 @@ module Puppet::Util::Firewall
 
     # Older iptables-persistent doesn't provide save action.
     if os_key == 'Debian'
-      Facter.fact(:iptables_persistent_version)
-      persist_ver = Facter.value(:iptables_persistent_version)
+      # We need to call flush to clear Facter cache as it's possible the cached value will be nil due to the fact
+      # that the iptables-persistent package was potentially installed after the initial Fact gathering.
+      fact = Facter.fact(:iptables_persistent_version)
+      fact.flush if fact.respond_to?(:flush)
+      persist_ver = fact.value
       if persist_ver && Puppet::Util::Package.versioncmp(persist_ver, '0.5.0') < 0
         os_key = 'Debian_manual'
       end