Last active
February 5, 2019 15:46
-
-
Save flannon/f5d8695447f3cc18b36e127eed410cbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prereqs for running molecule | |
yum install python2-devel python3-devel # linux olny | |
virtualenv --no-site-packages venv | |
source venv/bin/activate | |
pip install molecule ansible | |
pip install docker-py | |
# Initialize a new role | |
molecule init role -r new-role -d docker | |
source venv/bin/activate | |
cd new-role | |
molecule test | |
### initializing a role with molucule when selinux is active | |
The above does not work if selinux is enabled. There's an interestig discusison of selinux and ansible here, | |
https://dmsimard.com/2016/01/08/selinux-python-virtualenv-chroot-and-ansible-dont-play-nice/ | |
The option I used was to enable system-site-packages in the venv and then ignore installed when imporitng packages | |
with pip for the venv, as discussed here, | |
https://stackoverflow.com/a/19459977/3447107 | |
virtualenv --system-site-packages venv | |
source venv/bin/activate | |
pip install -I molecule ansible docker-py | |
molecule init role -r new-role -d docker | |
cd new-role2/ | |
molecule test | |
# Initializing an existing role | |
cd ansible-role-foo | |
molecule init scenario -r ansible-role-foo | |
# Docker in Docker build | |
# build | |
docker run --rm -it -v $(pwd):/tmp/$(basename "${PWD}") -w /tmp/$(basename "${PWD}") retr0h/molecule:latest molecule init role -r foo -d docker | |
# run | |
docker run --rm -it -v $(pwd):/tmp/$(basename "${PWD}") -v /var/run/docker.sock:/var/run/docker.sock -w /tmp/$(basename "${PWD}") retr0h/molecule:latest sudo molecule test | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment