-
Notifications
You must be signed in to change notification settings - Fork 39
/
tests.yml
84 lines (77 loc) · 2.36 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
- hosts: all
become: true
roles:
- role: '{{playbook_dir}}'
firewall_v6_configure: true
firewall_v4_flush_rules:
- -F
- -X
- -t raw -F
- -t raw -X
- -t mangle -F
- -t mangle -X
firewall_v4_group_rules:
400 allow http:
- -A INPUT -p tcp --dport http -j ACCEPT
400 allow 7890:
- -A INPUT -p tcp --dport 7890 -j ACCEPT
firewall_v4_host_rules:
400 allow 7890: []
firewall_v6_flush_rules:
- -F
- -X
- -t raw -F
- -t raw -X
- -t mangle -F
- -t mangle -X
firewall_v6_group_rules:
400 allow http:
- -A INPUT -p tcp --dport http -j ACCEPT
400 allow 7890:
- -A INPUT -p tcp --dport 7890 -j ACCEPT
firewall_v6_host_rules:
400 allow 7890: []
tasks:
- name: Retrieve v4 rules
command: iptables -L -n
changed_when: false
register: v4_rules
when: not ansible_check_mode
- name: Check that INPUT policy has been applied
assert:
that: "'Chain INPUT (policy DROP' in v4_rules.stdout"
when: not ansible_check_mode
- name: Check that a default rule has been applied
assert:
that: "'tcp dpt:22' in v4_rules.stdout"
when: not ansible_check_mode
- name: Check that a group rule has been applied
assert:
that: "'tcp dpt:80' in v4_rules.stdout"
when: not ansible_check_mode
- name: Check that deleted rules are deleted
assert:
that: "'tcp dpt:7890' not in v4_rules.stdout"
when: not ansible_check_mode
- name: Retrieve v6 rules
command: ip6tables -L -n
changed_when: false
register: v6_rules
when: not ansible_check_mode
- name: Check that INPUT policy has been applied
assert:
that: "'Chain INPUT (policy DROP' in v6_rules.stdout"
when: not ansible_check_mode
- name: Check that a default rule has been applied
assert:
that: "'tcp dpt:22' in v6_rules.stdout"
when: not ansible_check_mode
- name: Check that a group rule has been applied
assert:
that: "'tcp dpt:80' in v6_rules.stdout"
when: not ansible_check_mode
- name: Check that deleted rules are deleted
assert:
that: "'tcp dpt:7890' not in v6_rules.stdout"
when: not ansible_check_mode