-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
50 lines (41 loc) · 1.67 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
---
# We need sudo for some of the Docker commands.
sudo: required
env:
- init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# Tell Travis to start Docker when it brings up an environment.
services:
- docker
before_install:
# Pull container from Docker Hub.
- 'docker pull chrisjohnson00/ubuntu1604-ansible:1.0'
script:
# Create a random file to store the container ID.
- container_id=$(mktemp)
# Run container detached, with our role mounted inside.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-role-jackett:ro ${run_opts} chrisjohnson00/ubuntu1604-ansible:1.0 "${init}" > "${container_id}"'
# Check the role/playbook's syntax.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook /etc/ansible/roles/ansible-role-jackett/tests/test.yml --syntax-check
# Run the role/playbook with ansible-playbook.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook /etc/ansible/roles/ansible-role-jackett/tests/test.yml
# Run the role/playbook again, checking to make sure it's idempotent.
- idempotence=$(mktemp)
- >
docker exec "$(cat ${container_id})"
ansible-playbook /etc/ansible/roles/ansible-role-jackett/tests/test.yml
| tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=3.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Ensure responding on port 9117.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm /usr/bin/curl http://localhost:9117
notifications:
# Notify Ansible Galaxy when a role builds successfully.