Use modern Docker multi-OS tests.
parent
4ba0762493
commit
4f893912bb
47
.travis.yml
47
.travis.yml
|
|
@ -1,34 +1,47 @@
|
||||||
---
|
---
|
||||||
sudo: required
|
sudo: required
|
||||||
language: python
|
|
||||||
python: "2.7"
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- SITE=test.yml
|
- distro: centos7
|
||||||
|
init: /usr/lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
- distro: ubuntu1604
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
- distro: ubuntu1404
|
||||||
|
init: /sbin/init
|
||||||
|
run_opts: ""
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update -qq
|
# Pull container.
|
||||||
|
- 'sudo docker pull geerlingguy/docker-${distro}-ansible:latest'
|
||||||
install:
|
|
||||||
# Install Ansible.
|
|
||||||
- pip install ansible
|
|
||||||
|
|
||||||
# Add ansible.cfg to pick up roles path.
|
|
||||||
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Check the role/playbook's syntax.
|
- container_id=$(mktemp)
|
||||||
- "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
|
# 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}"'
|
||||||
|
|
||||||
# Run the role/playbook with ansible-playbook.
|
# Ansible syntax check.
|
||||||
- "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
|
- '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'
|
| 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.
|
||||||
|
- 'sudo docker stop "$(cat ${container_id})"'
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,4 @@ MIT / BSD
|
||||||
|
|
||||||
## Author Information
|
## Author Information
|
||||||
|
|
||||||
This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
|
This role was created in 2014 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
localhost
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- hosts: all
|
||||||
remote_user: root
|
|
||||||
roles:
|
roles:
|
||||||
- ansible-role-munin
|
- role_under_test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue