root / lib / facter / nftables.rb @ master
Historique | Voir | Annoter | Télécharger (716 octets)
1 | c82b960a | Steve Traylen | # frozen_string_literal: true
|
---|---|---|---|
2 | |||
3 | 03d9e7da | Steve Traylen | #
|
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 | 032387dc | Steve Traylen | # Produce the version of nftables (nft --version)
|
12 | # nftables v0.9.3 (Topsy)
|
||
13 | #
|
||
14 | 03d9e7da | Steve Traylen | 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 | c82b960a | Steve Traylen | tables.push(line.split[1, 2].join('-')) |
23 | 03d9e7da | Steve Traylen | end
|
24 | 032387dc | Steve Traylen | version = Facter::Core::Execution.execute(%(#{@nft_cmd} --version))[%r{^.*v(\d+\.\d+.\d+)\s.*$}, 1] |
25 | { |
||
26 | c82b960a | Steve Traylen | 'tables' => tables,
|
27 | 032387dc | Steve Traylen | 'version' => version,
|
28 | } |
||
29 | 03d9e7da | Steve Traylen | end
|
30 | end |