A code base for ansible projects that include :
- Vagrantfile
- Docker support
- Testinfra testing
Docker
, Vagrant
and Pip
have to be installed
Note : Vagrant >= 2.2.10 is required for ssh auto_correct port collision with docker (#9067).
Install python requirements :
$ python3 -m pip install virtualenv
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
This install virtualenv on your system and create an isolated environment with python requirements.
Start a container and provision it with Ansible :
$ vagrant up
Launch tests :
py.test -v
Code your infra and run playbooks with vagrant provision
Extra to this ansible-playbook command can be used directly : ansible-playbook site.yml
.
Write assert in *_test.py
files py.test
will run them within the container using Testinfra's Ansible connection backend.
Dockerfile : langouste/docker-vagrant-ready