view modules/firewall/lib/facter/iptables_persistent_version.rb @ 482:d83de9b3a62b default tip

Update hiera.yaml within Puppet config Forgot that we manage it from here. Now has content to match new packages
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Aug 2024 16:10:36 +0100
parents adf6fe9bbc17
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