Archlinux Docker image for Ansible role testing in Travis-CI.
1.2K
Archlinux Docker image for Ansible role testing in Travis-CI.
TL;DR:
docker pull kblr/archlinux-ansible
I use Docker in Travis-CI to test my Ansible roles on multiple OS.
This repo allows me to (automatically) build an Archlinux image from the provided Dockerfile. This image contains the needed tools to run Ansible and the tests.
The image is built by Docker Hub automatically each time one of the following happens:
master branch of this repo.Simply tell Travis to pull the image from Docker Hub and run a container based on it.
To do so, edit your molecule.yml file like this (just an example, the most important part is in the platforms section):
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: "kblr/archlinux-ansible:latest"
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: "playbook.yml"
scenario:
name: default
verifier:
name: testinfra
lint:
flake8
...
Your .travis.yml file should look like this:
sudo: required
language: bash
services:
- docker
before_install:
# Pull the image from Docker Hub:
- docker pull kblr/archlinux-ansible:latest
script:
# Run a container based on the previously pulled image:
- >
docker run
--name "${TRAVIS_COMMIT}.archlinux"
--detach
--privileged
--mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly
--mount type=bind,source="$(pwd)",target=/etc/ansible/roles/under_test,readonly
kblr/archlinux-ansible:latest
# Execute tests:
- >
docker exec "${TRAVIS_COMMIT}.archlinux"
ansible-playbook -v /etc/ansible/roles/under_test/tests/test/yml --syntax-check
- >
docker exec ...
after_script:
- docker rm -f "${TRAVIS_COMMIT}.archlinux"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
If you ever need to build the image manually:
git clone this repocd in the freshly cloned repodocker build --no-cache --rm --tag="archlinux:ansible" .cd in your Ansible role directorydocker run --name [whatever] --detach --privileged --mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly --mount type=bind,source="$(pwd)",target=/etc/ansible/roles/under_test,readonly archlinux:ansibleCode reviews, patches, comments, bug reports and feature requests are welcome. Please read the Contributing Guide for further details.
Content type
Image
Digest
sha256:994292d48…
Size
197.1 MB
Last updated
about 2 years ago
docker pull kblr/archlinux-ansible