`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.
More on Cloud, AWX, Windows and Molecule
`[WARNING]: * Failed to parse inventory/aws.yml with auto plugin: inventory source 'inventory/aws.yml' could not be verified by inventory plugin 'amazon.aws.aws_ec2'`IntermediateThe `aws_ec2` inventory parses without errors but returns zero hostsIntermediate`Failed to describe instances: An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation` or `(ExpiredToken)`IntermediateDynamic inventory finds the instances, but every host is `UNREACHABLE`IntermediateUsing the SSM connection plugin fails with `SessionManagerPlugin is not found` or hangs on file transferAdvanced`winrm or requests is not installed: No module named 'winrm'`Beginner