Skip to main content

Molecule aids in the development, and testing of Ansible roles.

Project description

PyPI Package Documentation Status Repository License

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, and OpenStack to manage virtual machines/containers, with support for multiple Vagrant providers (currently VirtualBox, Parallels, VMware Fusion, and Libvirt). Molecule supports Serverspec, Testinfra, or Goss (beta) to run tests. Molecule uses an Ansible playbook (playbook.yml), to execute the role and its tests.

Ansible Support

  • 1.9 - Not Supported

  • 2.0 - Not Supported

  • 2.1.4.0 - Supported

  • 2.2.1.0 - Supported

Dependencies

Molecule relies on several outside packages and programs to function.

Verifier

Driver

Provider

Quick Start

Install OS dependencies on CentOS 6/7

$ yum install -y epel-release
$ yum install gcc python-devel openssl-devel libffi-devel

Install OS dependencies on Ubuntu 16.x

$ apt-get update
$ apt-get install gcc python-pip python-vagrant libssl-dev libffi-dev

Install Molecule using pip:

$ pip install ansible
$ pip install docker-py
$ pip install molecule

Create a new role with the docker driver:

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

Or add Molecule to an existing role:

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

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

$ cd foo
$ molecule test
--> Destroying instances...
--> Checking playbook's syntax...

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

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

TASK [setup] *******************************************************************
ok: [foo]

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

--> Idempotence test in progress (can take a few minutes)...
--> Starting Ansible Run...
Idempotence test passed.
--> Performing a 'Dry Run' of playbook...

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

TASK [setup] *******************************************************************
ok: [foo]

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

--> Executing ansible-lint...
--> Executing flake8 on *.py files found in tests/...
--> Executing testinfra tests found in tests/...
============================= test session starts ==============================
platform darwin -- Python 2.7.12, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /private/tmp/foo, inifile: pytest.ini
plugins: testinfra-1.4.4
collected 1 itemss

tests/test_default.py .

============================ pytest-warning summary ============================
WP1 None Modules are already imported so can not be re-written: testinfra
================= 1 passed, 1 pytest-warnings in 0.89 seconds ==================
--> Destroying instances...
Stopping container foo...
Removed container foo.

Documentation

https://molecule.readthedocs.io/

License

MIT

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

molecule-1.20.1.tar.gz (5.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

molecule-1.20.1-py2-none-any.whl (90.2 kB view details)

Uploaded Python 2

File details

Details for the file molecule-1.20.1.tar.gz.

File metadata

  • Download URL: molecule-1.20.1.tar.gz
  • Upload date:
  • Size: 5.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for molecule-1.20.1.tar.gz
Algorithm Hash digest
SHA256 33f7113fd3cda9f49487c03f465bec9b30f6f31a61e8876850b9d75fd1eb0272
MD5 df0bf4ffbd5735c0bfc0c6fe9a020b12
BLAKE2b-256 aafaf6223707fb012d899107f8267827e21ba19e7d8fd501ad522cc2cc7b680a

See more details on using hashes here.

File details

Details for the file molecule-1.20.1-py2-none-any.whl.

File metadata

File hashes

Hashes for molecule-1.20.1-py2-none-any.whl
Algorithm Hash digest
SHA256 fc517fccda8943d43257856e64770531b0281214f5e73a3fd4e788c7573d602a
MD5 3dcc9e44ce9a8600ab642b9861174ccb
BLAKE2b-256 9cf1b083831e0b3c9644466c46fa9ef83fb4534f2d9b0db66e967a0b1552564a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page