Mercurial > repos > other > Puppet
annotate modules/firewall/lib/facter/iptables_persistent_version.rb @ 275:d9352a684e62
Mass update of modules to remove deprecation warnings
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 26 Jan 2020 11:36:07 +0000 |
parents | d6f2a0ee45c0 |
children | 66c406eec60d |
rev | line source |
---|---|
39 | 1 Facter.add(:iptables_persistent_version) do |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
2 confine operatingsystem: ['Debian', 'Ubuntu'] |
39 | 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) | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
8 cmd = if (os == 'Debian' && (Puppet::Util::Package.versioncmp(os_release, '8.0') >= 0)) || |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
9 (os == 'Ubuntu' && (Puppet::Util::Package.versioncmp(os_release, '14.10') >= 0)) || |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
10 (os == 'Debian' && (Puppet::Util::Package.versioncmp(os_release, 'unstable') >= 0)) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
11 "dpkg-query -Wf '${Version}' netfilter-persistent 2>/dev/null" |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
12 else |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
13 "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
14 end |
39 | 15 version = Facter::Util::Resolution.exec(cmd) |
16 | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
39
diff
changeset
|
17 if version.nil? || !version.match(%r{\d+\.\d+}) |
39 | 18 nil |
19 else | |
20 version | |
21 end | |
22 end | |
23 end |