Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / lib / facter / nftables.rb @ c82b960a

Historique | Voir | Annoter | Télécharger (716 octets)

1
# frozen_string_literal: true
2

    
3
#
4
# Produce an array of nftables.
5
# nft list tables
6
# table inet filter
7
# table ip nat
8
# table ip6 nat
9
# table inet f2b-table
10
#
11
# Produce the version of nftables (nft --version)
12
# nftables v0.9.3 (Topsy)
13
#
14
Facter.add(:nftables) do
15
  @nft_cmd = Facter::Util::Resolution.which('nft')
16
  confine { @nft_cmd }
17

    
18
  setcode do
19
    tables = []
20
    table_result = Facter::Core::Execution.execute(%(#{@nft_cmd} list tables))
21
    table_result.each_line do |line|
22
      tables.push(line.split[1, 2].join('-'))
23
    end
24
    version = Facter::Core::Execution.execute(%(#{@nft_cmd} --version))[%r{^.*v(\d+\.\d+.\d+)\s.*$}, 1]
25
    {
26
      'tables' => tables,
27
      'version' => version,
28
    }
29
  end
30
end