Skip to content
A wrapper script to make running Molecule easier
Shell
Branch: develop
Clone or download
Latest commit 12f1835 Sep 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
zsh Fixed Zsh support (#57) Sep 18, 2018
.editorconfig Added .editorconfig file Aug 29, 2018
.gitattributes Added .gitattributes Aug 29, 2018
.gitignore Added .gitignore Aug 29, 2018
.travis.yml Added script for creating the next version (#8) Sep 6, 2018
LICENSE Initial commit Aug 29, 2018
README.md
moleculew Prepare for next development iteration Sep 18, 2018
next-version.sh Pull develop branch before reading the version (#42) Sep 9, 2018

README.md

Molecule Wrapper

Build Status

A wrapper script (in the spirit of the Grade Wrapper) to make installing/running Molecule easier.

Note: this script currently only works on Linux.

Installation

In the root of your Ansible role run the following to install the wrapper:

wget 'https://raw.githubusercontent.com/gantsign/molecule-wrapper/master/moleculew' -O moleculew \
    && chmod 'u+x' moleculew

Tab completion and alias for Zsh

To enable tab-completion support and add an alias so you can run the wrapper using molecule follow these instructions.

Caution

Molecule has a lot of dependencies, some of which you'll need root privileges to install.

When you run the molecule wrapper for the first time it will attempt to install the following:

If you don't have root privileges see using system dependencies.

Usage

You can run any Molecule command directly using the wrapper e.g.:

./moleculew test

By default Molecule Wrapper runs using the latest versions of Python 2.x, Ansible, the Python Docker library and Molecule.

You can also specify particular versions of Python, Ansible, the Python Docker library and Molecule by passing command line arguments or setting environment variables:

Additional options:
  --ansible VERSION          Use the specified version of Ansible
  --docker-lib VERSION       Use the specified version of the Python Docker
                             library
  --molecule VERSION         Use the specified version of Molecule
  --python VERSION           Use the specified version of Python
  --use-system-dependencies  Use system dependencies

Environment variables:
  MOLECULEW_ANSIBLE     Use the specified version of Ansible
  MOLECULEW_DOCKER_LIB  Use the specified version of the Python Docker library
  MOLECULEW_MOLECULE    Use the specified version of Molecule
  MOLECULEW_PYTHON      Use the specified version of Python
  MOLECULEW_USE_SYSTEM  Use system dependencies (true/false)

The version may be a valid version number, latest to use the latest available version, or default to use the frozen version (if set) or otherwise use the latest version (i.e. the same effect as not specifying the option).

For the Python VERSION the values latest or latest2 will be the latest version of Python 2.x use latest3 for the latest version of Python 3.x.

The above command line arguments take preference over environment variables.

e.g.

./moleculew --python 3.6.6 test

Freezing versions

You can freeze the dependency versions by running the following command:

./moleculew wrapper-freeze

You can also specify versions when freezing the dependencies:

./moleculew --python 3.6.6 wrapper-freeze

Note: any version you specify as a command line argument when running Molecule will override the frozen version of that dependency.

Using system dependencies

If you don't have root privileges but you already have the necessary dependencies installed you can uses those dependencies by specifying --use-system-dependencies:

e.g.

./moleculew --use-system-dependencies test

Required dependencies:

The remaining dependencies don't require root privileges and will be installed if necessary.

This can also be useful for CI builds where you want to save time by using existing binaries.

Command line reference

wrapper-versions

Displays the current dependency versions being used:

Options:
  --ansible VERSION          Use the specified version of Ansible
  --docker-lib VERSION       Use the specified version of the Python Docker
                             library
  --molecule VERSION         Use the specified version of Molecule
  --python VERSION           Use the specified version of Python
  --use-system-dependencies  Use the system version of Python

Environment variables:
  MOLECULEW_ANSIBLE     Use the specified version of Ansible
  MOLECULEW_DOCKER_LIB  Use the specified version of the Python Docker library
  MOLECULEW_MOLECULE    Use the specified version of Molecule
  MOLECULEW_PYTHON      Use the specified version of Python
  MOLECULEW_USE_SYSTEM  Use system dependencies (true/false)

The version may be a valid version number, latest to use the latest available version, or default to use the frozen version (if set) or otherwise display the latest version (i.e. the same effect as not specifying the option).

For the Python VERSION the values latest or latest2 will be the latest version of Python 2.x use latest3 for the latest version of Python 3.x.

The above command line arguments take preference over environment variables.

e.g.

./moleculew wrapper-versions

wrapper-freeze

Freezes the dependency versions being used:

Options:
  --ansible VERSION          Use the specified version of Ansible
  --docker-lib VERSION       Use the specified version of the Python Docker
                             library
  --molecule VERSION         Use the specified version of Molecule
  --python VERSION           Use the specified version of Python
  --use-system-dependencies  Use the system version of Python

Environment variables:
  MOLECULEW_ANSIBLE     Use the specified version of Ansible
  MOLECULEW_DOCKER_LIB  Use the specified version of the Python Docker library
  MOLECULEW_MOLECULE    Use the specified version of Molecule
  MOLECULEW_PYTHON      Use the specified version of Python
  MOLECULEW_USE_SYSTEM  Use system dependencies (true/false)

The version may be a valid version number, latest to freeze to the latest available version, or default to keep the frozen version (if set) or otherwise freeze at the current latest version (i.e. the same effect as not specifying the option).

For the Python VERSION the values latest or latest2 will freeze to the current latest version of Python 2.x use latest3 to freeze to the current latest version of Python 3.x.

The above command line arguments take preference over environment variables.

e.g.

./moleculew wrapper-freeze

To upgrade one (or more) of the versions specify the options as follows:

./moleculew --ansible latest --molecule 2.16.0 wrapper-freeze

wrapper-unfreeze

Un-freezes the dependency versions:

e.g.

./moleculew wrapper-unfreeze

wrapper-upgrade-versions

Upgrades any frozen dependency versions to the latest version and freezes all dependency versions:

e.g.

./moleculew wrapper-upgrade-versions

wrapper-clean

Removes all the virtual environments created by Molecule Wrapper. The virtual environments can use up quite a bit of storage over time so you should run this periodically e.g. every few months.

e.g.

./moleculew wrapper-clean

wrapper-version

Displays the current version of the wrapper script.

e.g.

./moleculew wrapper-version

wrapper-upgrade

Upgrades the Molecule Wrapper to the latest version.

e.g.

./moleculew wrapper-upgrade

wrapper-install

Installs Molecule (if necessary). You don't need to use this because the other commands will run the install if they need to. This is included for CI environments where you might want to separate the console output for the install from the Molecule output.

Options:
  --ansible VERSION          Use the specified version of Ansible
  --docker-lib VERSION       Use the specified version of the Python Docker
                             library
  --molecule VERSION         Use the specified version of Molecule
  --python VERSION           Use the specified version of Python
  --use-system-dependencies  Use the system version of Python

Environment variables:
  MOLECULEW_ANSIBLE     Use the specified version of Ansible
  MOLECULEW_DOCKER_LIB  Use the specified version of the Python Docker library
  MOLECULEW_MOLECULE    Use the specified version of Molecule
  MOLECULEW_PYTHON      Use the specified version of Python
  MOLECULEW_USE_SYSTEM  Use system dependencies (true/false)

The version may be a valid version number, latest to freeze to the latest available version, or default to keep the frozen version (if set) or otherwise freeze at the current latest version (i.e. the same effect as not specifying the option).

For the Python VERSION the values latest or latest2 will freeze to the current latest version of Python 2.x use latest3 to freeze to the current latest version of Python 3.x.

The above command line arguments take preference over environment variables.

e.g.

./moleculew wrapper-install

wrapper-virtualenv

Displays the location of the Virtualenv environment.

Options:
  --ansible VERSION          Use the specified version of Ansible
  --docker-lib VERSION       Use the specified version of the Python Docker
                             library
  --molecule VERSION         Use the specified version of Molecule
  --python VERSION           Use the specified version of Python
  --use-system-dependencies  Use the system version of Python

Environment variables:
  MOLECULEW_ANSIBLE     Use the specified version of Ansible
  MOLECULEW_DOCKER_LIB  Use the specified version of the Python Docker library
  MOLECULEW_MOLECULE    Use the specified version of Molecule
  MOLECULEW_PYTHON      Use the specified version of Python
  MOLECULEW_USE_SYSTEM  Use system dependencies (true/false)

The version may be a valid version number, latest to freeze to the latest available version, or default to keep the frozen version (if set) or otherwise freeze at the current latest version (i.e. the same effect as not specifying the option).

For the Python VERSION the values latest or latest2 will freeze to the current latest version of Python 2.x use latest3 to freeze to the current latest version of Python 3.x.

The above command line arguments take preference over environment variables.

e.g.

./moleculew wrapper-virtualenv

License

This software is licensed under the terms in the file named "LICENSE" in the root directory of this project. This project has dependencies that are under different licenses.

Author Information

John Freeman

GantSign Ltd. Company No. 06109112 (registered in England)

You can’t perform that action at this time.