2016-02-09 06:01:57 +01:00
|
|
|
---
|
2015-12-12 11:17:40 +01:00
|
|
|
sudo: required
|
2015-12-13 21:06:12 +01:00
|
|
|
|
2014-04-22 14:39:07 +02:00
|
|
|
env:
|
2016-08-29 03:23:31 +02:00
|
|
|
global:
|
|
|
|
# https://github.com/travis-ci/travis-ci/issues/6461#issuecomment-239577306
|
|
|
|
DOCKER_VERSION: "1.9.1-0~trusty"
|
|
|
|
matrix:
|
|
|
|
- repository: geerlingguy/docker-centos7-ansible
|
|
|
|
version: latest
|
|
|
|
init: /usr/lib/systemd/systemd
|
|
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
|
|
- repository: geerlingguy/docker-centos6-ansible
|
|
|
|
version: latest
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
2016-08-29 03:33:01 +02:00
|
|
|
- repository: geerlingguy/docker-ubuntu1604-ansible
|
|
|
|
version: latest
|
|
|
|
init: /lib/systemd/systemd
|
|
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
2016-08-29 03:23:31 +02:00
|
|
|
- repository: geerlingguy/docker-ubuntu1404-ansible
|
|
|
|
version: latest
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
|
|
|
- repository: geerlingguy/docker-ubuntu1204-ansible
|
|
|
|
version: latest
|
|
|
|
init: /sbin/init
|
|
|
|
run_opts: ""
|
2014-04-23 19:59:07 +02:00
|
|
|
|
2015-12-12 11:17:40 +01:00
|
|
|
services:
|
|
|
|
- docker
|
2014-04-23 19:59:07 +02:00
|
|
|
|
2015-12-12 11:17:40 +01:00
|
|
|
before_install:
|
2016-08-29 03:23:31 +02:00
|
|
|
# Downgrade to specific version of Docker engine.
|
|
|
|
- sudo apt-get update
|
|
|
|
- sudo apt-get remove docker-engine -yq
|
|
|
|
- sudo apt-get install docker-engine=$DOCKER_VERSION -yq --no-install-suggests --no-install-recommends --force-yes -o Dpkg::Options::="--force-confnew"
|
|
|
|
|
2016-08-29 03:12:26 +02:00
|
|
|
# Pull container.
|
2016-08-29 03:14:10 +02:00
|
|
|
- 'sudo docker pull ${repository}:${version}'
|
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-08-29 03:12:26 +02:00
|
|
|
# Run container in detached state.
|
|
|
|
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${repository}:${version} "${init}" > "${container_id}"'
|
2015-12-12 11:17:40 +01:00
|
|
|
|
2015-12-13 21:06:12 +01:00
|
|
|
# Ansible syntax check.
|
|
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
|
|
|
|
|
|
|
# Test role.
|
|
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
|
|
|
|
|
|
|
# Test role idempotence.
|
2016-08-29 05:10:47 +02:00
|
|
|
- idempotence=$(mktemp)
|
|
|
|
- sudo 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)
|
|
|
|
|
2015-12-13 21:06:12 +01:00
|
|
|
# Clean up
|
|
|
|
- 'sudo docker stop "$(cat ${container_id})"'
|
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/
|