File: iptables_persistent_version.rb

package info (click to toggle)
puppet-module-puppetlabs-firewall 8.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 512 kB
  • sloc: ruby: 2,674; sh: 39; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 492 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

Facter.add(:iptables_persistent_version) do
  confine 'os.name': ['Debian', 'Ubuntu']
  setcode do
    # Throw away STDERR because dpkg >= 1.16.7 will make some noise if the
    # package isn't currently installed.
    cmd = "dpkg-query -Wf '${Version}' netfilter-persistent 2>/dev/null"
    version = Facter::Core::Execution.execute(cmd, { on_fail: nil })

    if version.nil? || !version.match(%r{\d+\.\d+})
      nil
    else
      version
    end
  end
end