Ansible role for installing molecule
into a Python3 VirtualEnv.
This role has been tested on Ansible 2.7.0+ against the following Linux Distributions:
- Amazon Linux 2
- CentOS 8
- CentOS 7
- Debian 10
- Fedora 29
- Fedora 30
- Fedora 31
- Ubuntu 18.04 LTS
If you have any problems please create a GitHub issue, I maintain this role in my spare time so I cannot promise a speedy fix delivery.
Variable | Description | Default Value |
---|---|---|
molecule_version |
Use a specific version of molecule, eg. 2.22.0 . Specify false for latest. |
false |
molecule_support_packages |
Install molecule support packages (eg. Docker) | [] |
molecule_install_dir |
Installation directory to put molecule virtual environments. | $HOME/.virtualenvs |
molecule_venv_name |
Name for the molecule Virtualenv. | molecule |
molecule_venv_suffix |
Add a custom suffix to virtualenv. | molecule_version |
molecule_venv_site_packages |
Allow venv to inherit packages from global site-packages. | false |
molecule_install_venv_helper |
Install a venv helper to launch venv executables from a "bin" directory. | true |
molecule_bin_dir |
"bin" directory to install venv-helpers to. | $HOME/bin |
molecule_install_os_dependencies |
Allow role to install OS dependencies. | false |
molecule_python3_path |
Specify a path to a specific python version to use in virtualenv. | NULL |
No dependencies on other roles.
Example playbook for installing to single user:
- hosts: molecule_hosts
roles:
- { role: xanmanning.molecule, molecule_version: 2.22.0 }
Example playbook for installing the latest molecule version globally:
---
- hosts: molecule_hosts
become: true
vars:
molecule_install_os_dependencies: true
molecule_install_dir: /opt/molecule/bin
molecule_bin_dir: /usr/bin
molecule_venv_name: current
molecule_support_packages:
- docker
- lint
roles:
- role: xanmanning.molecule
You need to activate the python3 virtual environment to be able to access molecule
.
This is done as per the below:
source {{ molecule_install_dir }}/{{ molecule_venv_name }}/bin/activate
In the above example global installation playbook, this would look like the following:
source /opt/molecule/bin/current/bin/activate