Ansible AWS S3 – Fix ‘amazon.aws.s3_object’ Module Not Found

amazon s3amazon-web-servicesansiblepython

Per requirements, I did installed all the required packages, however amazon.aws.s3_object is one of those things:

  • couldn't be resolved/found
  • was not found in configured module paths

step(s), I used to re-produce my issue:

% docker run -it debian:stable-slim bash
root@6140e6e2c06c:/# apt-get -qq update && apt-get -yqq install ansible python3-boto3 python3-botocore
root@6140e6e2c06c:/# uname -a
Linux 6140e6e2c06c 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 GNU/Linux
root@6140e6e2c06c:/# cat /etc/debian_version
11.7
root@6140e6e2c06c:/# ansible --version
ansible 2.10.8
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
root@6140e6e2c06c:/# python3 --version
Python 3.9.2
root@6140e6e2c06c:/#
root@6140e6e2c06c:/# ansible localhost -m amazon.aws.s3_object
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | FAILED! => {
    "msg": "The module amazon.aws.s3_object was not found in configured module paths"
}
root@6140e6e2c06c:/#...

Thank you in advance!

Best Answer

Quote from the documentation:

This module is part of the amazon.aws collection (version 5.4.0).

...

To install it, use: ansible-galaxy collection install amazon.aws

root@befa2662325b:/# ansible-galaxy collection install amazon.aws
root@befa2662325b:/# ansible localhost -m amazon.aws.s3_object
localhost | FAILED! => {
    "changed": false,
    "msg": "missing required arguments: bucket, mode"
}

Alternatively, instead of working with the horribly outdated versions of Ansible and related packages, install Ansible via pip.

root@2b8f31d78667:/# apt install python3 python3-pip
root@2b8f31d78667:/# python3 -m pip install ansible
root@2b8f31d78667:/# ansible --version
ansible [core 2.14.6]
root@2b8f31d78667:/#
root@2b8f31d78667:/# ansible-galaxy collection list |grep aws
amazon.aws                    5.5.0
root@2b8f31d78667:/# ansible localhost -m amazon.aws.s3_object
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | FAILED! => {
    "changed": false,
    "msg": "missing required arguments: bucket, mode"
}