gpt4 book ai didi

python - Ansible 需要 python-apt 但它已经安装

转载 作者:行者123 更新时间:2023-12-02 01:19:10 25 4
gpt4 key购买 nike

Prologue: I am just moving first stesp in ansible, so please be patient

Also: I read the answers at 'Ansible demands installing MySQL-python despite it was already installed' but my case is different because locally, on the control machine, is all perfect; thanks to this question I discovered that my problem was in the remote controlled machine. So my questions is the same but the question linked do not contains an answer to resolve my problem.

我正在从命令行测试ansible。例如我可以成功ping通

~/.ssh$ ansible openvpn -C -m "ping"
192.168.1.225 | SUCCESS => {
"changed": false,
"ping": "pong"
}

我尝试启动 apt 更新

I am not sure if this is the right syntax for having the equivalent of apt-get update, but this is not the question

I am using -C to see what ansible says to me when I ask to do a dry run.

$ ansible openvpn -C -m "apt update-cache=yes"
192.168.1.225 | FAILED! => {
"changed": false,
"msg": "python-apt must be installed to use check mode. If run normally this module can auto-install it."
}

编辑:正如@Davide Maze所建议的,这可能是由于缺少python-apt。所以我检查了,但是_我有python-apt

$ python -V
Python 2.7.15rc1

$ pip list
... cut ...
python-apt (1.6.2)
... cut ...

$ which python
/usr/bin/python

我的问题是:为什么 ansible 告诉我 python-apt 没有安装,以及如何解决这个问题?

最佳答案

我在运行 ansible-playbook 时使用 ansible_python_interpreter 参数解决了此错误,如下所示。

ansible-playbook playbook_name.yml -e ansible_python_interpreter=/usr/bin/python --check

关于python - Ansible 需要 python-apt 但它已经安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51622712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com