39
|
1 Facter.add(:iptables_persistent_version) do
|
|
2 confine :operatingsystem => %w{Debian Ubuntu}
|
|
3 setcode do
|
|
4 # Throw away STDERR because dpkg >= 1.16.7 will make some noise if the
|
|
5 # package isn't currently installed.
|
|
6 os = Facter.value(:operatingsystem)
|
|
7 os_release = Facter.value(:operatingsystemrelease)
|
|
8 if (os == 'Debian' and (Puppet::Util::Package.versioncmp(os_release, '8.0') >= 0)) or
|
|
9 (os == 'Ubuntu' and (Puppet::Util::Package.versioncmp(os_release, '14.10') >= 0))
|
|
10 cmd = "dpkg-query -Wf '${Version}' netfilter-persistent 2>/dev/null"
|
|
11 else
|
|
12 cmd = "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null"
|
|
13 end
|
|
14 version = Facter::Util::Resolution.exec(cmd)
|
|
15
|
|
16 if version.nil? or !version.match(/\d+\.\d+/)
|
|
17 nil
|
|
18 else
|
|
19 version
|
|
20 end
|
|
21 end
|
|
22 end
|