Bootstrap FreeKB - Ansible - Resolve "boto3 required for this module"
Ansible - Resolve "boto3 required for this module"

Updated:   |  Ansible articles

Let's say something like this is being returned.

fatal: []: FAILED! => {"changed": false, "msg": "boto3 required for this module"}


I first happened upon this when attempting to use an AWS module.

- hosts: all
  - name: register aws_s3_bucket_info
    register: out


Ansible will be configured to use a particular version of Python, such as Python2 or Python3. Check out my article Setting Python version using ansible_python_interpreter. I would start by first determining the version of Python being used by Ansible. 

- hosts: localhost
  - debug:
      var: ansible_python_interpreter


Running this playbook should return something like this.

ok: [localhost] => {
    "ansible_python_interpreter": "/usr/bin/python2"


If Ansible is using Python2 such as /usr/bin/python2 then you will want to use Python2 pip list command to determine if the boto package is installed in Python2.

If Ansible is using Python3 such as /usr/bin/python3 then you will want to use Python3 pip list command to determine if the boto3 package is installed in Python3.

~]$ /usr/bin/python3 -m pip list
Package                            Version
---------------------------------- ------------------
ansible                            2.9.12
certifi                            2020.6.20
cffi                               1.14.2
chardet                            3.0.4
cryptography                       3.0
idna                               2.10
Jinja2                             2.11.2
lxml                               4.5.2
MarkupSafe                         1.1.1
pip                                20.2.3
pycparser                          2.20
pyOpenSSL                          19.1.0
pyvmomi                            7.0
PyYAML                             5.3.1
requests                           2.24.0
setuptools                         49.6.0
six                                1.15.0
suds-jurko                         0.6
urllib3                            1.25.10
vapi-client-bindings               3.3.0
vapi-common-client                 2.15.0
vapi-runtime                       2.15.0
vmc-client-bindings                1.26.0
vmc-draas-client-bindings          1.10.0
vSphere-Automation-SDK             1.32.0


Before you can use the Ansible Amazon Web Services (AWS) modules, you will need to install the AWS CLI tool on the hosts that will be using the Ansible Amazon Web Services (AWS) modules. Check out my article Getting Started with the AWS CLI. The which command can be used to determine if the AWS CLI exists in $PATH. In this example, the AWS CLI does exist in $PATH.

~]$ which aws


After you setup the AWS CLI, you will then set your Amazon Web Services (AWS) Profile ConfigurationsCheck out my article Set Amazon Web Services (AWS) Profile Configurations.

Assuming the boto or boto3 package is not installed, the Ansible pip module can be used to install the boto or boto3 package. I would run this on localhost (the Ansible server) otherwise each and every target server would need to have the boto3 package installed. It's much easier to just have the boto3 package installed on the Ansible server.

- hosts: localhost
  gather_facts: false
  - name: which aws
    shell: which aws
    register: which

  - debug:
      var: which

  - name: pip install boto3
      name: boto3
      state: latest

  - name: testing aws_s3_bucket_info
    register: result


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 0531a7 in the box below so that we can be sure you are a human.