Mercurial > repos > other > Puppet
diff modules/firewall/lib/facter/iptables_persistent_version.rb @ 39:d6f2a0ee45c0 puppet-3.6
Add "Firewall" module
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 14 Mar 2015 20:58:03 +0000 |
parents | |
children | d9352a684e62 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/firewall/lib/facter/iptables_persistent_version.rb Sat Mar 14 20:58:03 2015 +0000 @@ -0,0 +1,22 @@ +Facter.add(:iptables_persistent_version) do + confine :operatingsystem => %w{Debian Ubuntu} + setcode do + # Throw away STDERR because dpkg >= 1.16.7 will make some noise if the + # package isn't currently installed. + os = Facter.value(:operatingsystem) + os_release = Facter.value(:operatingsystemrelease) + if (os == 'Debian' and (Puppet::Util::Package.versioncmp(os_release, '8.0') >= 0)) or + (os == 'Ubuntu' and (Puppet::Util::Package.versioncmp(os_release, '14.10') >= 0)) + cmd = "dpkg-query -Wf '${Version}' netfilter-persistent 2>/dev/null" + else + cmd = "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" + end + version = Facter::Util::Resolution.exec(cmd) + + if version.nil? or !version.match(/\d+\.\d+/) + nil + else + version + end + end +end