view modules/firewall/lib/facter/iptables_persistent_version.rb @ 478:adf6fe9bbc17

Update Puppet modules to latest versions
author IBBoard <dev@ibboard.co.uk>
date Thu, 29 Aug 2024 18:47:29 +0100
parents 66c406eec60d
children
line wrap: on
line source

# frozen_string_literal: true

Facter.add(:iptables_persistent_version) do
  confine operatingsystem: ['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