forked from CyVerse-Ansible/ansible-geoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
70 lines (61 loc) · 3.37 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
---
sudo: required
services:
- docker
env:
- distribution: centos
version: 7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: ubuntu
version: 15.04
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: ubuntu
version: 16.04
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
before_install:
# Pull image
- 'sudo docker pull cyverse/ansible-test:2.1.1-${distribution}-${version}'
script:
- container_id=$(mktemp)
# Run container in detached state
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} cyverse/ansible-test:2.1.1-${distribution}-${version} "${init}" > "${container_id}"'
## TEST: Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
#################
#### TEST: 1 ####
#################
- >
sudo docker exec "$(cat ${container_id})" ls /usr/share/GeoIP &>/dev/null
&& (echo 'This directory should not yet exist: fail' && exit 1)
|| (echo 'This directory does not yet exist: pass' && exit 0)
## Run role with default paramters
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
## Verify database copied into place
- >
sudo docker exec "$(cat ${container_id})" ls /usr/share/GeoIP/GeoLiteCity.dat
&& (echo '/usr/share/GeoIP/GeoLiteCity.dat extracted: pass' && exit 0)
|| (echo '/usr/share/GeoIP/GeoLiteCity.dat not extracted: fail' && exit 1)
## Test role idempotence
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
###################
#### TEST: 1.1 ####
###################
## Test that the `geo_ip_override` variable forces the update.
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --extra-vars "geo_ip_override=true"
| grep -q 'changed=2.*failed=0'
&& (echo 'Changes detected: pass' && exit 0)
|| (echo 'NO CHANGES detected: fail' && exit 1)
## Cleanup
- 'sudo docker stop "$(cat ${container_id})"'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
slack:
secure: Z/br0a3oI3FnWbM6kgitXKqiEB9b57IoexhJQ1Pf0XF/KKglGwUVPlHDe1ms12OdnsTfbOoI6xD2vHNKUbqF7rrqSgOLZ2n4XZxJmvSMi2gkY9YvnSu5HLeM0Wwgy1DbftBfqYtQYS7/eHIDPCNulPgTd27qtxJCkiCmU5UpNyDYlLNcVsIG2U7GT6pESixelJbVd70c2cIGJMbIziOTNCm7mzm1PT/vI2reVBMYp8dBq1kgt3zhQbU7cY6cAEOMVNNOOd+Yh3+vU1ureZqfXnCblvJ0YWV2UBH3UOyp2NFWyjwjkoYYBQBaVCPgrRwgiCL++8wMiadxeDWbaIwU1AoN+3t7wSzZHkBdM2WRZtTf2KOuVNHtCtRmhmD6zmWsSJRQanAW457jAgaMXpZ4Cf/2R7Dxw+aWY2teGs+vjW1UdTNi8FP/S1AgylYAV7wcjnd2BB2EYdAh1vqIVAk2dvbVRKHONvaGYi6rS+0ZnCYMSN7mNFTwbXMcvtOC2cFewKtC0UzMwpm10M7cTK0ebqorY1BggCx9OYZmaSt7l2pAQpDJoXnsdqtkueJKod6GDSoo9WgbKTTqDiw97k7gHpqbDK4WB4j2DOaxseam6FzJdEN0Z+bE2F9qHJ9rXZUvfZaia9RAsrzYoHkPAvSoAEXSq85lYktiwscNEXhZwE0=