This repo provides a cookiecutter template that will allow you to initialize a test scenario using molecule to connect to a vSphere server as a VM provider. Note, ESXi alone will not work because this requires templates and the ability to clone VMs.
The molecule.yml
file allows for multiple nodes listed in platforms
with the usual convention of
defining group membership and inventory vars.
- python >= 2.6
- PyVmomi
- Molecule >= 2.0
- Ansible >= 2.4
- sshpass (installed command)
- rsync (installed command)
molecule init --url gh:perched/molecule-cookiecutter-vsphere
# Edit molecule/default/molecule.yml to your needs
# Edit molecule/default/create.yml to change the `ssh_user` and `ssh_pass` until I find a fix
# Add testinfra tests to molecule/default/tests dir
molecule test
The molecule documentation doesn't cover this super well, but the above example will initialize a test scenario for the options that you give it (it will prompt you).
In your project with top-level molecule directory, create a file .env.yml
with the credentials for vSphere:
---
VMWARE_USER: "[email protected]"
VMWARE_PASSWORD: "its-a-secret-to-everybody"
Then to run all the tests, simply do:
docker run --rm -ti -v $(pwd):/src \
-w /src quay.io/perched/molecule-vsphere test --all