Projet

Général

Profil

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

root / spec / acceptance / default_spec.rb @ bd5145ab

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

1 bd5145ab Steve Traylen
require 'spec_helper_acceptance'
2
3
describe 'nftables class' do
4
  context 'configure default nftables service' do
5
    it 'works idempotently with no errors' do
6
      pp = <<-EOS
7
      # default mask of firewalld service fails if service is not installed.
8
      # https://tickets.puppetlabs.com/browse/PUP-10814
9
      class { 'nftables':
10
        firewalld_enable => false,
11
      }
12
      # nftables cannot be started in docker so replace service with a validation only.
13
      systemd::dropin_file{"zzz_docker_nft.conf":
14
        ensure  => present,
15
        unit    => "nftables.service",
16
        content => [
17
          "[Service]",
18
          "ExecStart=",
19
          "ExecStart=/sbin/nft -c -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf",
20
          "ExecReload=",
21
          "ExecReload=/sbin/nft -c -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf",
22
          "",
23
          ].join("\n"),
24
        notify  => Service["nftables"],
25
      }
26
      # Puppet 5 only to ensure ordering.
27
      Class['systemd::systemctl::daemon_reload'] -> Service['nftables']
28
      EOS
29
      # Run it twice and test for idempotency
30
      apply_manifest(pp, catch_failures: true)
31
      apply_manifest(pp, catch_changes: true)
32
    end
33
34
    describe package('nftables') do
35
      it { is_expected.to be_installed }
36
    end
37
38
    describe service('nftables') do
39
      it { is_expected.to be_running }
40
      it { is_expected.to be_enabled }
41
    end
42
43
    describe file('/etc/nftables/puppet.nft') do
44
      it { is_expected.to be_file }
45
    end
46
47
    describe file('/etc/nftables/puppet') do
48
      it { is_expected.to be_directory }
49
    end
50
  end
51
end