mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-03 08:40:18 +01:00
Update travisfile to not require sudo.
This commit is contained in:
parent
0b7cd353c0
commit
379e1cd11f
1 changed files with 24 additions and 35 deletions
59
.travis.yml
59
.travis.yml
|
@ -1,61 +1,50 @@
|
||||||
---
|
---
|
||||||
sudo: required
|
services: docker
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
- distro: centos7
|
||||||
# https://github.com/travis-ci/travis-ci/issues/6461#issuecomment-239577306
|
init: /usr/lib/systemd/systemd
|
||||||
DOCKER_VERSION: "1.9.1-0~trusty"
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
matrix:
|
- distro: centos6
|
||||||
- distro: centos7
|
init: /sbin/init
|
||||||
init: /usr/lib/systemd/systemd
|
run_opts: ""
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
- distro: ubuntu1604
|
||||||
- distro: centos6
|
init: /lib/systemd/systemd
|
||||||
init: /sbin/init
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
run_opts: ""
|
- distro: ubuntu1404
|
||||||
- distro: ubuntu1604
|
init: /sbin/init
|
||||||
init: /lib/systemd/systemd
|
run_opts: ""
|
||||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
- distro: ubuntu1204
|
||||||
- distro: ubuntu1404
|
init: /sbin/init
|
||||||
init: /sbin/init
|
run_opts: ""
|
||||||
run_opts: ""
|
|
||||||
- distro: ubuntu1204
|
|
||||||
init: /sbin/init
|
|
||||||
run_opts: ""
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Pull container.
|
# Pull container.
|
||||||
- 'sudo docker pull geerlingguy/docker-${distro}-ansible:latest'
|
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- container_id=$(mktemp)
|
- container_id=$(mktemp)
|
||||||
# Run container in detached state.
|
# Run container in detached state.
|
||||||
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
||||||
|
|
||||||
# Ansible syntax check.
|
# 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'
|
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
||||||
|
|
||||||
# Test role.
|
# Test role.
|
||||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
||||||
|
|
||||||
# Test role idempotence.
|
# Test role idempotence.
|
||||||
- idempotence=$(mktemp)
|
- idempotence=$(mktemp)
|
||||||
- sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
||||||
- >
|
- >
|
||||||
tail ${idempotence}
|
tail ${idempotence}
|
||||||
| 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)
|
||||||
|
|
||||||
|
after_success:
|
||||||
# Clean up.
|
# Clean up.
|
||||||
- 'sudo docker stop "$(cat ${container_id})"'
|
- 'docker stop "$(cat ${container_id})"'
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|
Loading…
Reference in a new issue