Commit d0c687a8 authored by Jérémy Viau-Trudel's avatar Jérémy Viau-Trudel
Browse files

provide a bootstrap script

parent 6fb821ad
......@@ -6,9 +6,21 @@ Un playbook ansible doit
- être idempotent
- fonctionner dans tout les cas ou échouer le plus rapidement possible (principe fail-fast)
## Quickstart
source bootstrap.sh # check dependencies and setup initial environment
## Dependencies
Run `./bootstrap.sh` to check dependencies and setup your local environment.
- python3 + pip3
- virtualenv
- docker
## Références
- [iHow To Test Ansible Roles with Molecule on Ubuntu 16.04. Tutoriel DigitalOcean par Varun Chopra](https://www.digitalocean.com/community/tutorials/how-to-test-ansible-roles-with-molecule-on-ubuntu-16-04)
- [Code source du projet molecule](https://github.com/ansible/molecule)
- [Testing your Ansible roles with Molecule. Article de blogue par Jeff Geerling](https://www.jeffgeerling.com/blog/2018/testing-your-ansible-roles-molecule)
- [Testing Strategies. Ansible documentation.](https://docs.ansible.com/ansible/latest/reference_appendices/test_strategies.html)
......
#! /bin/bash
#
# Préparation de l'emvironement
VerifyPython3(){
python3 --help >> /dev/null
if [ $? -ne 0 ]; then
echo "python is not available"
fail=1
fi
}
VerifyPip3(){
pip3 --help >> /dev/null
if [ $? -ne 0 ]; then
echo "pip3 is not available"
fail=1
fi
}
VerifyDocker(){
docker --help >> /dev/null
if [ $? -ne 0 ]; then
echo "docker is not available"
fail=1
fi
}
VerifyVirtualenv(){
virtualenv --help >> /dev/null
if [ $? -ne 0 ]; then
echo "virtualenv is not available"
fail=1
fi
}
fail=0
VerifyPython3
VerifyPip3
VerifyDocker
VerifyVirtualenv
if [ $fail -ne 0 ]; then
echo "One or more dependencies are not present."
exit 1
fi
if [ -d ".venv" ]; then
echo "A virtual environment already exists. Do you want to erase it? [y/N]"
read erase
if [ $erase == "y" ]; then
rm -rf .venv
virtualenv -p python3 .venv
fi
else
virtualenv -p python3 .venv
fi
source .venv/bin/activate
pip3 install -r requirements.txt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment