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