我已经在一台新的不可失控制服务器(Debian 11)上验证了我的Python3、模块路径和集合路径。但是,当将ansible-inventory --list
命令指向Google gcp.yml库存文件时,我会得到以下错误:
[WARNING]: * Failed to parse /home/user/CODE/ops/ansible/inventory/gcp-dynamic/demo3/gcp.yml with
ansible_collections.google.cloud.plugins.inventory.gcp_compute plugin: gce inventory plugin cannot start: Failed to import the required Python library
(google-auth) on server's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location
这是完整的库存命令:ansible-inventory --list -i /path/to/gcp.yml
这是gcp.yml文件:
---
plugin: gcp_compute
projects:
- project9
auth_kind: serviceaccount
service_account_file: /home/user/.config/credentials.json
# setup group parasing prefix=inventory label
keyed_groups:
- key: labels
prefix: demo3
这是我的ansible --version
输出:
ansible [core 2.13.2]
config file = /home/user/.ansible.cfg
configured module search path = ['/home/user/.local/lib/python3.9/site-packages/ansible/modules']
ansible python module location = /home/user/.local/lib/python3.9/site-packages/ansible
ansible collection location = /home/user/.local/lib/python3.9/site-packages/ansible_collections
executable location = /home/user/.local/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
jinja version = 3.1.2
libyaml = True
这是pip3 show google-auth
的输出
Name: google-auth
Version: 2.10.0
Summary: Google Authentication Library
Home-page: https://github.com/googleapis/google-auth-library-python
Author: Google Cloud Platform
Author-email: googleapis-packages@google.com
License: Apache 2.0
Location: /home/user/.local/lib/python3.9/site-packages
Requires: cachetools, pyasn1-modules, rsa, six
Required-by:
在我的~/.ansible.cfg中我有:
# (pathspec) Colon separated paths in which Ansible will search for Modules.
library=/home/user/.local/lib/python3.9/site-packages/ansible/modules:/home/user/.local/lib/python3.9/site-packages
对下一步该做什么有什么建议吗?
发布于 2022-08-20 20:14:26
我在非标文档规定的通过pip安装Ansible和apt之间来回走了一圈。
我终于让这个动态库存与这个设置一起工作了:
来自GCP的Debian11基VM,然后以根用户身份执行所有操作:(/usr/bin/ python 3) pip ansible google-auth
我确保将所有附加包添加为root,而不是针对单个用户进行安装:
pip --安装了带有apt:sudo apt install python3-pip
的pip
使用apt:sudo apt install ansible
安装
google-auth -也安装为root:sudo pip3 install google-auth
似乎主要的问题是pip
和apt
之间的安装方法不匹配。在这种情况下,当我通过apt做所有事情,而不是通过pip安装Ansible时,所有的东西都整理好了。
https://stackoverflow.com/questions/73354185
复制相似问题