mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-04 09:10:17 +01:00
Remove duplicate code, use build matrix
This commit is contained in:
parent
33c4876d51
commit
940968d86f
1 changed files with 12 additions and 35 deletions
47
.travis.yml
47
.travis.yml
|
@ -1,62 +1,39 @@
|
||||||
sudo: required
|
sudo: required
|
||||||
env:
|
env:
|
||||||
- CONTAINER_ID=$(mktemp)
|
- container_id=$(mktemp) distribution=centos version=7
|
||||||
|
- container_id=$(mktemp) distribution=ubuntu version=14.04
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
# Pull containers
|
# Pull container
|
||||||
- sudo docker pull centos:7
|
- sudo docker pull ${distribution}:${version}
|
||||||
- sudo docker pull ubuntu:14.04
|
# Customize container
|
||||||
# Customize containers
|
- sudo docker build --rm=true --file=tests/Dockerfile.${distribution} --tag=${distribution}:ansible tests
|
||||||
- sudo docker build --rm=true --file=tests/Dockerfile.centos --tag=centos:ansible tests
|
|
||||||
- sudo docker build --rm=true --file=tests/Dockerfile.ubuntu --tag=ubuntu:ansible tests
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
#
|
#
|
||||||
# Run test playbook on Ubuntu container
|
# Run test playbook
|
||||||
#
|
#
|
||||||
|
|
||||||
# Run container in detached state
|
# Run container in detached state
|
||||||
- sudo docker run --detach ubuntu:ansible /sbin/init > "${CONTAINER_ID}"
|
- sudo docker run --detach ${distribution}:ansible /sbin/init > "${container_id}"
|
||||||
|
|
||||||
|
|
||||||
# Syntax check
|
# 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
|
# 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
|
# Idempotence test
|
||||||
- >
|
- >
|
||||||
sudo docker exec "$(cat ${CONTAINER_ID})" ansible-playbook /etc/ansible/test.yml
|
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/test.yml
|
||||||
| grep -q 'changed=0.*failed=0'
|
| grep -q 'changed=0.*failed=0'
|
||||||
&& (echo 'Idempotence test: pass' && exit 0)
|
&& (echo 'Idempotence test: pass' && exit 0)
|
||||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|| (echo 'Idempotence test: fail' && exit 1)
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
- sudo docker stop "$(cat ${CONTAINER_ID})"
|
- sudo docker stop "$(cat ${container_id})"
|
||||||
|
|
||||||
#
|
|
||||||
# Run test playbook on CentOS container
|
|
||||||
#
|
|
||||||
|
|
||||||
# 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}"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
# 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
|
|
||||||
- sudo docker stop "$(cat ${CONTAINER_ID})"
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
Loading…
Reference in a new issue