每要求,我确实安装了所有必需的软件包,但是amazon.aws.s3_object
其中之一:
couldn't be resolved/found
was not found in configured module paths
步骤,我曾经重现过我的问题:
% 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:/#...
先感谢您!
答案1
引自文档:
此模块属于amazon.aws 集合(版本 5.4.0)。
...
要安装它,请使用:
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"
}
或者,不要使用严重过时的 Ansible 和相关软件包版本,而是通过 pip 安装 Ansible。
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"
}
答案2
语境:
- 您安装的版本是 Ansible 2.10.8
shell> root@6140e6e2c06c:/# ansible --version
ansible 2.10.8
...
- 该系列亚马逊默认情况下,Ansible 2.10.8 中应已安装。请参阅建造
amazon.aws: >=1.2.0,<2.0.0
- 模块s3_对象已添加到收藏夹中亚马逊版本 1.0.0。请参阅来源
DOCUMENTATION = r"""
---
module: s3_object
version_added: 1.0.0
short_description: Manage objects in S3
- 您尚未创建任何配置然而
root@6140e6e2c06c:/# ansible --version
ansible 2.10.8
config file = None
解决方案:
确保集合包含在COLLECTIONS_PATH。 例如,
shell> ansible-config dump | grep COLLECTIONS_PATHS
COLLECTIONS_PATHS(/scratch/tmp7/test-353/ansible.cfg) = ['/home/admin/.local/lib/python3.9/site-packages']
shell> find /home/admin/.local/lib/python3.9/site-packages -name s3_object.py
/home/admin/.local/lib/python3.9/site-packages/ansible_collections/amazon/aws/plugins/action/s3_object.py
/home/admin/.local/lib/python3.9/site-packages/ansible_collections/amazon/aws/plugins/modules/s3_object.py
根据您所在的位置更改路径已安装收藏品。
笔记:
可以同时安装多个版本的 Ansible 集合。您可以自行配置要使用的版本的路径。