-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
42 lines (32 loc) · 1.19 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
---
# https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
language: python
python: "2.7"
env:
- PLAYBOOK=tests/test-travis.yml
INVENTORY=tests/inventory-travis
before_install:
# Make sure everything's up to date.
- sudo apt-get update
install:
# Install Ansible.
- pip install ansible
# Add ansible.cfg to pick up roles path.
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
# Automatically create the inventory
- "echo 'localhost' > $INVENTORY"
script:
# Check the role/playbook's syntax.
- "ansible-playbook -i $INVENTORY $PLAYBOOK --syntax-check"
# Run the role/playbook with ansible-playbook.
- "ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local --sudo"
# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Request a page via the web server, to make sure it's running and responds.
#- curl --head --insecure https://localhost/
# Verify a known port is opened
- sudo netstat -tlnp | grep ":58846"