Interview Prep/Ansible/Cloud, AWX, Windows and Molecule

`Failed to import the required Python library (botocore and boto3) on web01's Python /usr/bin/python3.`

BeginnerTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes → AWS modules (amazon.aws.*) run wherever the task runs. Here the task ran on the managed host web01, which has no boto3. Normally AWS API calls should run on the controller, with hosts: localhost or delegate_to: localhost. When they do run there, the controller's Python (or virtualenv, or EE) may be missing boto3.

Diagnose → The message names the host and the interpreter. Check with "{{ ansible_playbook_python }}" -c 'import boto3, botocore'.

Fix →

- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - amazon.aws.ec2_instance_info:
        region: ap-south-1
        filters: {"tag:Env": prod}

Then pip install boto3 botocore into the controller environment.

Prevent → Build boto3 into the execution environment (requirements.txt in ansible-builder), and keep API plays on localhost.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule