forked from tschifftner/ansible-role-fail2ban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
executable file
·65 lines (51 loc) · 1.83 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
---
sudo: required
dist: trusty
language: python
python: "2.7"
env:
- SITE=test.yml ANSIBLE_VERSION=latest
- SITE=test.yml ANSIBLE_VERSION=2.1.0.0
branches:
only:
- master
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y curl
install:
# Install Ansible.
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install --no-binary ansible ansible; else pip install --no-binary ansible ansible==$ANSIBLE_VERSION; fi
# Add ansible.cfg to pick up roles path.
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
# Install ansible-lint
- pip install ansible-lint
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)
# ansible-lint checks for best practice
#- ansible-lint tests/$SITE
# Make sure fail2ban is installed.
- >
(ps ax | grep fail2ban-server | wc -l) > 1
&& (echo 'fail2ban is installed' && exit 0)
|| (echo 'fail2ban is not installed' && exit 1)
after_failure:
- ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
- sudo service fail2ban status
- sudo fail2ban-client status
- sudo which fail2ban-client status
- sudo cat /etc/fail2ban/fail2ban.local
- ansible --version
- ansible-lint --version
- ansible -i 127.0.0.1, -m setup all -c local
notifications:
slack: ambimax:2MlPTX9bY9aPxCPhJGxHKIT6
webhooks: https://galaxy.ansible.com/api/v1/notifications/