Installing Ansible and Molecule in Ubuntu Linux

Using “pip” is the supported installation method for Ansible and Molecule. In Ubuntu, just using “pip” will lead to the error “externally-managed-environment” because of the Python environment that is “externally managed” by the package manager (this prevents direct use of pip for system-wide installations to avoid conflicts or issues).

(This post is similar to the one about Arch Linux.)

Instead, let’s install Python libraries and applications (in this case, Ansible and Molecule) in a Python virtual environment.

First, install the required packages, including the Python virtual environment package:

Create a virtual environment somewhere (in this example, I create it in my home folder as a subdirectory of a folder for all the virtual environments; the directory will be created automatically):

Once the virtual environment has been created, “enter” the virtual environment:

Install the Python packages for Ansible, Molecule, and its plugins in the virtual environment:

You can verify that everything is installed correctly, e.g., at the time of writing:

Each time you want to run Ansible or Molecule, just run the “source” command above:

And then you can run “ansible” and “molecule”.

One thought on “Installing Ansible and Molecule in Ubuntu Linux

  1. Pingback: Installing Ansible and Molecule in Arch Linux | Lorenzo Bettini

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.