forked from geerlingguy/ansible-role-firewall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
98 lines (77 loc) · 2.59 KB
/
.travis.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
sudo: required
language: python
python: "2.7"
env:
- SITE=test.yml
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y curl
install:
# Install Ansible.
- pip install ansible
# Add ansible.cfg to pick up roles path.
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
script:
# Check the role/playbook's syntax.
- "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
# Run the role/playbook with ansible-playbook.
- "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Check if TCP port 9123 is open.
- >
sudo iptables -L -n
| grep -q "ACCEPT.*dpt:9123"
&& (echo 'Port 9123 is open - pass' && exit 0)
|| (echo 'Port 9123 is not open - fail' && exit 1)
# Check if TCP port 8123 is open.
- >
sudo ip6tables -L -n
| grep -q "ACCEPT.*dpt:8123"
&& (echo 'Port 9123 is open - pass' && exit 0)
|| (echo 'Port 9123 is not open - fail' && exit 1)
# Check running firewall has exit code 0
- >
sudo service firewall status
&& (echo 'Status of running firewall is 0 - pass' && exit 0)
|| (echo 'Status of running firewall is not 0 - fail' && exit 1)
# Check running firewall6 has exit code 0
- >
sudo service firewall6 status
&& (echo 'Status of running firewall6 is 0 - pass' && exit 0)
|| (echo 'Status of running firewall6 is not 0 - fail' && exit 1)
# Stop firewall
- >
sudo service firewall stop
&& (echo 'Stopping firewall - pass' && exit 0)
|| (echo 'Stopping firewall - fail' && exit 1)
# Stop firewall6
- >
sudo service firewall6 stop
&& (echo 'Stopping firewall6 - pass' && exit 0)
|| (echo 'Stopping firewall6 - fail' && exit 1)
# Check stopped firewall has exit code 3
- >
sudo service firewall status;
EXIT=$?;
if [ 3 -eq $EXIT ]; then
echo 'Status of stopped firewall is 3 - pass' && exit 0;
else
echo 'Status of stopped firewall is not 3 - fail' && exit 1;
fi
# Check stopped firewall6 has exit code 3
- >
sudo service firewall6 status;
EXIT=$?;
if [ 3 -eq $EXIT ]; then
echo 'Status of stopped firewall6 is 3 - pass' && exit 0;
else
echo 'Status of stopped firewall6 is not 3 - fail' && exit 1;
fi
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/