Skip to content

rjfellman/molecule

 
 

Repository files navigation

Molecule

PyPI Package

Documentation Status

Build Status

Requirements Status

Molecule is designed to aid in the development and testing of Ansible roles including support for multiple instances, operating system distributions, virtualization providers and test frameworks.

It leverages Vagrant, Docker, OpenStack, and libvirt to manage virtual machines/containers, with support for multiple Vagrant providers (currently VirtualBox, Parallels and VMware Fusion). Molecule supports Serverspec or Testinfra to run tests. Molecule uses an Ansible playbook (playbook.yml), to execute the role and its tests.

Ansible Support

  • 1.9.6 - Limited (Docker driver not-supported by Ansible)
  • 2.0.2.0 - Supported
  • 2.1.1.0 - Supported

Quick Start

Install molecule using pip:

$ pip install molecule

Create a new role with the docker driver:

$ molecule init foo --docker
--> Initializing role foo...
Successfully initialized new role in ./foo

Or add molecule to an existing role:

$ cd foo
$ molecule init --docker
--> Initializing molecule in current directory...
Successfully initialized new role in /private/tmp

Update the role with needed functionality and tests. Now test it:

$ cd foo
$ molecule test
--> Destroying instances ...
--> Checking playbooks syntax ...

playbook: playbook.yml
--> Creating instances ...
--> Creating Ansible compatible image of ubuntu:latest ...
--> Creating Ansible compatible image of ubuntu:latest ...
Creating container foo-01 with base image ubuntu:latest ...
Container created.
Creating container foo-02 with base image ubuntu:latest ...
Container created.
--> Starting Ansible Run ...

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
ok: [foo-01]
ok: [foo-02]

PLAY RECAP *********************************************************************
foo-01                     : ok=1    changed=0    unreachable=0    failed=0
foo-02                     : ok=1    changed=0    unreachable=0    failed=0

--> Idempotence test in progress (can take a few minutes)...
--> Starting Ansible Run ...
Idempotence test passed.
--> Executing testinfra tests found in tests/.
============================= test session starts ==============================
platform darwin -- Python 2.7.11, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /private/tmp/foo/tests, inifile:
plugins: mock-1.1, xdist-1.14, testinfra-1.3.1
collected 2 itemss

tests/test_default.py ..

=========================== 2 passed in 1.11 seconds ===========================
No serverspec tests found in spec/.
--> Destroying instances ...
Stopping container foo-01 ...
Removed container foo-01.
Stopping container foo-02 ...
Removed container foo-02.

Documentation

http://molecule.readthedocs.org/en/latest/

License

MIT

The logo is licensed under the Creative Commons NoDerivatives 4.0 License. If you have some other use in mind, contact us.

About

Automated testing for Ansible roles

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 90.1%
  • Shell 7.9%
  • Ruby 2.0%