summaryrefslogtreecommitdiffstats
path: root/.travis.yml
diff options
context:
space:
mode:
Diffstat (limited to '.travis.yml')
-rw-r--r--.travis.yml55
1 files changed, 38 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml
index 11a7369..668ba3b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,34 +1,55 @@
---
sudo: required
-language: python
-python: "2.7"
env:
- - SITE=test.yml
+ - 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"
+ - distribution: ubuntu
+ version: 14.04
+ init: /sbin/init
+ run_opts: ""
+ - distribution: ubuntu
+ version: 12.04
+ init: /sbin/init
+ run_opts: ""
+
+services:
+ - docker
before_install:
- - sudo apt-get update -qq
-
-install:
- # Install Ansible.
- - pip install ansible
-
- # Add ansible.cfg to pick up roles path.
- - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
+ # Pull container
+ - 'sudo docker pull ${distribution}:${version}'
+ # Customize container
+ - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
script:
- # Check the role/playbook's syntax.
- - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
+ - container_id=$(mktemp)
+ # Run container in detached state
+ - 'sudo docker run --detach -p 8025:8025 --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
- # Run the role/playbook with ansible-playbook.
- - "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
+ # 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'
- # Run the role/playbook again, checking to make sure it's idempotent.
+ # 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.
+ - idempotence=$(mktemp)
+ - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
- >
- ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
+ tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
+ # Clean up
+ - 'sudo docker stop "$(cat ${container_id})"'
+
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/