Add idempotence test

This commit is contained in:
Bert Van Vreckem 2015-12-12 11:29:05 +01:00
parent 5d73dbbb94
commit 0060d6d1c8

View file

@ -18,8 +18,17 @@ script:
# #
# Run test playbook on Ubuntu container # Run test playbook on Ubuntu container
# #
# Syntax check
- sudo docker run ubuntu:ansible ansible-playbook /etc/ansible/test.yml --syntax-check - sudo docker run ubuntu:ansible ansible-playbook /etc/ansible/test.yml --syntax-check
# Test role
- sudo docker run ubuntu:ansible ansible-playbook /etc/ansible/test.yml - sudo docker run ubuntu:ansible ansible-playbook /etc/ansible/test.yml
# Idempotence test
- >
sudo docker run ubuntu:ansible ansible-playbook /etc/ansible/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# #
# Run test playbook on CentOS container # Run test playbook on CentOS container
@ -28,8 +37,17 @@ script:
# Run container in detached state # Run container in detached state
- sudo docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro centos:ansible /usr/lib/systemd/systemd > "${CONTAINER_ID}" - sudo docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro centos:ansible /usr/lib/systemd/systemd > "${CONTAINER_ID}"
# Syntax check
- sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml --syntax-check - sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml --syntax-check
# Test role
- sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml - sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml
# Idempotence test
- >
sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Clean up # Clean up
- sudo docker stop "$(cat ${CONTAINER_ID})" - sudo docker stop "$(cat ${CONTAINER_ID})"