Projet

Général

Profil

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

root / spec / acceptance / simple_rule_iifname_spec.rb @ 25b3f3f4

Historique | Voir | Annoter | Télécharger (1,99 ko)

1
# frozen_string_literal: true
2

    
3
require 'spec_helper_acceptance'
4

    
5
describe 'nftables class' do
6
  context 'configure a simple rule with input interface' do
7
    it_behaves_like 'an idempotent resource' do
8
      let(:manifest) do
9
        <<-EOS
10
        # default mask of firewalld service fails if service is not installed.
11
        # https://tickets.puppetlabs.com/browse/PUP-10814
12
        # Disable all default rules and include below explicitly
13
        class { 'nftables':
14
          firewalld_enable => false,
15
          out_ntp          => false,
16
          out_http         => false,
17
          out_https        => false,
18
          out_icmp         => false,
19
          in_ssh           => false,
20
          in_icmp          => false,
21
        }
22
        nftables::simplerule { 'dummyrule_in':
23
          action  => 'accept',
24
          iifname => $facts['networking']['primary'],
25
          comment => 'allow some multicast stuff',
26
          daddr   => 'ff02::fb',
27
        }
28
        include nftables::rules::ssh
29
        include nftables::rules::out::dns
30
        include nftables::rules::out::ssh
31
        $config_path = $facts['os']['family'] ? {
32
          'Archlinux' => '/etc/nftables.conf',
33
          'Debian' => '/etc/nftables.conf',
34
          default => '/etc/sysconfig/nftables.conf',
35
        }
36
        $nft_path = $facts['os']['family'] ? {
37
          'Archlinux' => '/usr/bin/nft',
38
          default => '/usr/sbin/nft',
39
        }
40
        # nftables cannot be started in docker so replace service with a validation only.
41
        systemd::dropin_file{"zzz_docker_nft.conf":
42
          ensure  => present,
43
          unit    => "nftables.service",
44
          content => [
45
            "[Service]",
46
            "ExecStart=",
47
            "ExecStart=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
48
            "ExecReload=",
49
            "ExecReload=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
50
            "",
51
            ].join("\n"),
52
          notify  => Service["nftables"],
53
        }
54
        EOS
55
      end
56
    end
57
  end
58
end