Configures something on a server. More info here.
- Ansible
- Tested Versions:
- 2.8
- 2.9
- Tested Versions:
ansible-galaxy install git+https://github.com/joshuacherry/example-ansible-role.git
- something
- Support different options on different platforms
OS | Option 1 |
---|---|
Ubuntu 16.04 | ✓ |
ubuntu 18.04 | ✓ |
Centos 7 | ✓ |
Centos 8 | ✓ |
- something 3
For the versions available, see the tags on this repository.
Additionally you can see what change in each version in the CHANGELOG.md file.
Look to the defaults properties file to see the possible configuration properties.
This role includes a Vagrantfile used with a Docker-based test harness that approximates the Travis CI setup for integration testing. Using Vagrant allows all contributors to test on the same platform and avoid false test failures due to untested or incompatible docker versions.
This molecule configuration depends on docker images from https://hub.docker.com/u/joshuacherry/ to quickly test the role against a variety of operating systems.
- Install Vagrant and VirtualBox.
- Run
vagrant up
from the same directory as the Vagrantfile in this repository. - SSH into the VM with:
vagrant ssh
- Run tests with
molecule
.
Tox will test against the configured dependencies in tox.ini. This allows you to test the role against multiple version of ansible, molecule, python, and more. Once the dependencies are set, tox will run the same molecule command to test code.
Due to how Virtualbox mounts shared folders, it is recommended to copy the role into a local directory within the virtual machine before running tox, otherwise the python environments will perform significantly slower. Run the below commands each time you make a change to the source code and need to test against all scenarios defined in tox.ini
rsync -ua /example-ansible-role/ ~/example-ansible-role/ --delete
cd ~/example-ansible-role
tox
This method will only test the code with the most recent version of Ansible, tox testing should be used before commits to master so that all scenarios can be tested.
cd /example-ansible-role
molecule test
See molecule
for more information including a full list of available commands.
You can use log into a docker image created by molecule for interactive testing with the below commands. As defined in molecule.yml, the default instance is set to ubuntu1604
. If you wish to test other operating systems, you must define the environment variables MOLECULE_DISTRO
and MOLECULE_DOCKER_COMMAND
. A table of supported options are below.
cd /example-ansible-role
export MOLECULE_DISTRO=centos7
export MOLECULE_DOCKER_COMMAND=/usr/lib/systemd/systemd
molecule converge
docker exec -it instance /bin/bash
OS | MOLECULE_DISTRO | MOLECULE_DOCKER_COMMAND |
---|---|---|
Ubuntu 16.04 | ubuntu1604 | /lib/systemd/systemd |
ubuntu 18.04 | ubuntu1804 | /lib/systemd/systemd |
Centos 7 | centos7 | /usr/lib/systemd/systemd |
Centos 8 | centos8 | /usr/lib/systemd/systemd |
---
- name: Playbook for example-ansible-role
hosts: all
tasks:
- include_role:
name: example-ansible-role