Why can't the supported or custom-built Execution Environment find the modules already installed in it on Ansible Automation Platform?

Solution Verified - Updated -

Environment

  • Red Hat® Ansible Automation Platform

Issue

  • When using one of the supported or custom-built Execution Environments during an automation run, why is an error received about not being able to find a module that is present in the Execution Environment?

Resolution

  • Set the following parameter within your playbook or through host/extravars section in the Inventory on Automation Controller:

    ansible_python_interpreter: "{{ ansible_playbook_python }}"
    
  • Images may be built upon existing base images which already include Python. Auto-discovery may pick up the wrong version first.

Root Cause

  • When using localhost with [default] auto python discovery, the system may pick up the wrong python interpreter due to having multiple versions within the Execution Environment. By setting the parameter it points to the correct one and removes the error.

Diagnostic Steps

  • Check the Job output which fails with the below error message:

    "msg": "<module> is not installed, try 'pip install <module>'"
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments