mirror of
https://github.com/geerlingguy/ansible-role-ansible.git
synced 2024-11-25 12:05:11 +01:00
Use Docker to test on multiple OSes.
This commit is contained in:
parent
72fee3c820
commit
3c9ca4f3f4
63
.travis.yml
63
.travis.yml
@ -1,39 +1,60 @@
|
||||
---
|
||||
sudo: required
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
env:
|
||||
- SITE=test.yml
|
||||
- repository: geerlingguy/docker-centos7-ansible
|
||||
version: latest
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- repository: geerlingguy/docker-centos6-ansible
|
||||
version: latest
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
- repository: geerlingguy/docker-ubuntu1604-ansible
|
||||
version: latest
|
||||
init: /lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- repository: geerlingguy/docker-ubuntu1404-ansible
|
||||
version: latest
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
- repository: geerlingguy/docker-ubuntu1204-ansible
|
||||
version: latest
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y curl
|
||||
|
||||
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 ${repository}:${version}'
|
||||
|
||||
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 --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${repository}:${version} "${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)
|
||||
|
||||
# Make sure Ansible is installed (yes, this is contrived, since Ansible was
|
||||
# already installed via pip earlier...).
|
||||
- "which ansible"
|
||||
# Ensure Ansible is installed (contrived... since it's already installed).
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which ansible'
|
||||
|
||||
# Clean up.
|
||||
- 'sudo docker stop "$(cat ${container_id})"'
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
@ -6,7 +6,7 @@ galaxy_info:
|
||||
description: Ansible for RedHat/CentOS/Debian/Ubuntu.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.4
|
||||
min_ansible_version: 1.8
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
|
@ -1 +0,0 @@
|
||||
localhost
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
- hosts: all
|
||||
|
||||
roles:
|
||||
- ansible-role-ansible
|
||||
- role_under_test
|
||||
|
Loading…
Reference in New Issue
Block a user