52 lines
2.4 KiB
YAML
52 lines
2.4 KiB
YAML
|
language: python
|
||
|
services:
|
||
|
- docker
|
||
|
|
||
|
env:
|
||
|
- ANSIBLE_VERSION: "2.9.27"
|
||
|
- ANSIBLE_VERSION: "2.10.7"
|
||
|
- ANSIBLE_VERSION: "3.4.0"
|
||
|
- ANSIBLE_VERSION: "4.10.0"
|
||
|
- distribution: Ubuntu
|
||
|
distribution_version: bionic
|
||
|
init: /lib/systemd/systemd
|
||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||
|
ANSIBLE_VERSION: docker
|
||
|
- distribution: Ubuntu
|
||
|
distribution_version: xenial
|
||
|
init: /lib/systemd/systemd
|
||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||
|
ANSIBLE_VERSION: docker
|
||
|
- distribution: Debian
|
||
|
distribution_version: buster
|
||
|
init: /lib/systemd/systemd
|
||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||
|
ANSIBLE_VERSION: docker
|
||
|
|
||
|
before_install:
|
||
|
# Standard Local Testing Commands
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then sudo apt-get -y install software-properties-common ; fi
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then sudo apt-get -y install python-pip ; fi
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then sudo pip install ansible==$ANSIBLE_VERSION ; fi
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then ansible --version ; fi
|
||
|
# Docker Testing pull container.
|
||
|
- if [ "${ANSIBLE_VERSION}" == "docker" ]; then docker pull ansiblecheck/ansiblecheck:${distribution,,}-${distribution_version} ; fi
|
||
|
|
||
|
|
||
|
script:
|
||
|
# Local Testing Commands
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then echo localhost > inventory ; fi
|
||
|
- if [ "${ANSIBLE_VERSION}" != "docker" ]; then ansible-playbook -i inventory --connection=local --become -v test/main.yml ; fi
|
||
|
|
||
|
# Docker Testing Commands
|
||
|
- if [ "${ANSIBLE_VERSION}" == "docker" ]; then container_id=$(mktemp) ; fi
|
||
|
# Start The Built Container In The Background
|
||
|
- if [ "${ANSIBLE_VERSION}" == "docker" ]; then docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ansiblecheck/ansiblecheck:"${distribution,,}"-"${distribution_version}" "${init}" > "${container_id}" ; fi
|
||
|
# Ansible syntax check.
|
||
|
- if [ "${ANSIBLE_VERSION}" == "docker" ]; then docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/test/main.yml --syntax-check ; fi
|
||
|
# Test role.
|
||
|
- if [ "${ANSIBLE_VERSION}" == "docker" ]; then docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/test/main.yml -v -e update_cache=1; fi
|
||
|
|
||
|
notifications:
|
||
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|