从 ansible CLI 执行时出现 winrm 问题

问题描述 投票:0回答:1

我想用python3运行ansible,但是ansible版本的输出仍然显示python 2版本,即使我通过ansible_python_interpreter

#ansible-playbook --version -e 'ansible_python_interpreter=/usr/bin/python3'
ansible-playbook 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 2.7.5 (default, xxxx, xx:xx:xx) [GCC 4.8.5 2015xx (Red Hat 4.8.5-44)]

如何强制ansible使用python 3?

当我执行 win_ping 时,出现以下错误

"msg": "winrm or requests is not installed: No module named winrm"

检查 winrm 和请求:

# python3
Python 3.6.8 (default, xx xx 2023, 08:41:09)
[GCC 4.8.5 2015xxx (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import winrm
>>> import requests
>>>
ansible winrm
1个回答
0
投票

请检查您是否有

python3
,位于
/usr/bin/python3
。然后尝试添加到
ansible.cfg

ansible_python_interpreter=/usr/bin/python3
© www.soinside.com 2019 - 2024. All rights reserved.