2016-02-09 06:01:57 +01:00
|
|
|
---
|
2016-09-25 21:45:34 +02:00
|
|
|
services: docker
|
2015-12-13 21:06:12 +01:00
|
|
|
|
2014-04-22 14:39:07 +02:00
|
|
|
env:
|
2016-09-25 21:45:34 +02:00
|
|
|
- distro: centos7
|
|
|
|
init: /usr/lib/systemd/systemd
|
|
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
|
|
- distro: centos6
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
|
|
|
- distro: ubuntu1604
|
|
|
|
init: /lib/systemd/systemd
|
|
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
|
|
- distro: ubuntu1404
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
|
|
|
- distro: ubuntu1204
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
2014-04-23 19:59:07 +02:00
|
|
|
|
2015-12-12 11:17:40 +01:00
|
|
|
before_install:
|
2016-08-29 03:12:26 +02:00
|
|
|
# Pull container.
|
2016-09-25 21:45:34 +02:00
|
|
|
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
|
2014-04-23 19:59:07 +02:00
|
|
|
|
2014-04-22 14:39:07 +02:00
|
|
|
script:
|
2015-12-14 09:07:17 +01:00
|
|
|
- container_id=$(mktemp)
|
2016-09-25 21:45:34 +02:00
|
|
|
# Run container in detached state.
|
|
|
|
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
2015-12-12 11:17:40 +01:00
|
|
|
|
2015-12-13 21:06:12 +01:00
|
|
|
# Ansible syntax check.
|
2016-09-25 21:45:34 +02:00
|
|
|
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
2015-12-13 21:06:12 +01:00
|
|
|
|
|
|
|
# Test role.
|
2016-09-25 21:45:34 +02:00
|
|
|
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
2015-12-13 21:06:12 +01:00
|
|
|
|
|
|
|
# Test role idempotence.
|
2016-08-29 05:10:47 +02:00
|
|
|
- idempotence=$(mktemp)
|
2016-09-25 21:45:34 +02:00
|
|
|
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
2015-12-12 11:29:05 +01:00
|
|
|
- >
|
2016-08-29 05:10:47 +02:00
|
|
|
tail ${idempotence}
|
2015-12-12 11:29:05 +01:00
|
|
|
| grep -q 'changed=0.*failed=0'
|
|
|
|
&& (echo 'Idempotence test: pass' && exit 0)
|
|
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|
|
|
|
|
2016-02-01 19:21:26 +01:00
|
|
|
notifications:
|
2016-02-08 20:50:39 +01:00
|
|
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|