|
1 | 1 | --- |
2 | | -sudo: required |
| 2 | +services: docker |
3 | 3 |
|
4 | 4 | env: |
5 | | - global: |
6 | | - # https://github.com/travis-ci/travis-ci/issues/6461#issuecomment-239577306 |
7 | | - DOCKER_VERSION: "1.9.1-0~trusty" |
8 | | - matrix: |
9 | | - - repository: geerlingguy/docker-centos7-ansible |
10 | | - version: latest |
11 | | - init: /usr/lib/systemd/systemd |
12 | | - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" |
13 | | - - repository: geerlingguy/docker-centos6-ansible |
14 | | - version: latest |
15 | | - init: /sbin/init |
16 | | - run_opts: "" |
17 | | - - repository: geerlingguy/docker-ubuntu1604-ansible |
18 | | - version: latest |
19 | | - init: /lib/systemd/systemd |
20 | | - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" |
21 | | - - repository: geerlingguy/docker-ubuntu1404-ansible |
22 | | - version: latest |
23 | | - init: /sbin/init |
24 | | - run_opts: "" |
25 | | - - repository: geerlingguy/docker-ubuntu1204-ansible |
26 | | - version: latest |
27 | | - init: /sbin/init |
28 | | - run_opts: "" |
29 | | - |
30 | | -services: |
31 | | - - docker |
| 5 | + - distro: centos7 |
| 6 | + init: /usr/lib/systemd/systemd |
| 7 | + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" |
| 8 | + - distro: centos6 |
| 9 | + init: /sbin/init |
| 10 | + run_opts: "" |
| 11 | + - distro: ubuntu1604 |
| 12 | + init: /lib/systemd/systemd |
| 13 | + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" |
| 14 | + - distro: ubuntu1404 |
| 15 | + init: /sbin/init |
| 16 | + run_opts: "" |
| 17 | + - distro: ubuntu1204 |
| 18 | + init: /sbin/init |
| 19 | + run_opts: "" |
32 | 20 |
|
33 | 21 | before_install: |
34 | | - # Downgrade to specific version of Docker engine. |
35 | | - - sudo apt-get update |
36 | | - - sudo apt-get remove docker-engine -yq |
37 | | - - sudo apt-get install docker-engine=$DOCKER_VERSION -yq --no-install-suggests --no-install-recommends --force-yes -o Dpkg::Options::="--force-confnew" |
38 | | - |
39 | 22 | # Pull container. |
40 | | - - 'sudo docker pull ${repository}:${version}' |
| 23 | + - 'docker pull geerlingguy/docker-${distro}-ansible:latest' |
41 | 24 |
|
42 | 25 | script: |
43 | 26 | - container_id=$(mktemp) |
44 | | - # Run container in detached state. |
45 | | - - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${repository}:${version} "${init}" > "${container_id}"' |
| 27 | + # Run container in detached state. |
| 28 | + - 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' |
46 | 29 |
|
47 | 30 | # Ansible syntax check. |
48 | | - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' |
| 31 | + - 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' |
49 | 32 |
|
50 | 33 | # Test role. |
51 | | - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' |
| 34 | + - 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' |
52 | 35 |
|
53 | 36 | # Test role idempotence. |
| 37 | + - idempotence=$(mktemp) |
| 38 | + - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} |
54 | 39 | - > |
55 | | - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml |
| 40 | + tail ${idempotence} |
56 | 41 | | grep -q 'changed=0.*failed=0' |
57 | 42 | && (echo 'Idempotence test: pass' && exit 0) |
58 | 43 | || (echo 'Idempotence test: fail' && exit 1) |
59 | 44 |
|
60 | | - # Clean up |
61 | | - - 'sudo docker stop "$(cat ${container_id})"' |
62 | | - |
63 | 45 | notifications: |
64 | 46 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
0 commit comments