-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy path.travis.yml
63 lines (53 loc) · 1.76 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
sudo: required
env:
global:
- container_id: $(mktemp)
- role: /etc/ansible/roles/role_under_test
- test_playbook: ${role}/tests/test.yml
matrix:
- distribution: ubuntu # Linux distribution
version: 12.04 # Distribution version
init: /sbin/init # Path to init executable (differs for SysVInit/Systemd)
run_opts: "" # Additional options for running the Docker container
- distribution: ubuntu
version: 14.04
init: /sbin/init
run_opts: ""
- distribution: centos
version: 6
init: /sbin/init
run_opts: ""
- distribution: centos
version: 7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
services:
- docker
before_install:
- sudo apt-get update
- sudo apt-get --yes install dnsutils
# Pull container
- sudo docker pull bertvv/ansible-testing:${distribution}_${version}
script:
# Run container in detached state
- >
sudo docker run --detach --volume="${PWD}:${role}:ro" ${run_opts}
bertvv/ansible-testing:${distribution}_${version} "${init}" > "${container_id}"
# Ansible syntax check.
- >
sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook ${test_playbook} --syntax-check
# Test role.
- >
sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook ${test_playbook}
# Test role idempotence.
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook ${test_playbook}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- >
"${role}/tests/runbats.sh" || ls -R "${role}"
# Clean up
- 'sudo docker stop "$(cat ${container_id})"'