步骤一:打开ansible.cfg配置文件 首先,你需要找到ansible.cfg文件。一般情况下,该文件位于/etc/ansible/ansible.cfg或者~/.ansible.cfg。 步骤二:找到[defaults]部分 在打开的ansible.cfg文件中,找到[defaults]部分。这个部分包含了ansible的默认配置信息。 步骤三:添加或修改ansible_python_interpreter变量 在[defaults]...
globally, use the interpreter_python key in the [defaults] section of ansible.cfg 配置文件: [defaults]python_interpreter=/usr/bin/python [defaults]python_interpreter=/usr/bin/python3 命令行: ansible -i hosts all -m shell -a 'date' -e 'ansible_python_interpreter=/usr/bin/python3' ...
1.Paramiko组件(python的ssh连接库) 2. PyYAML组件(python的YAML解析器库) 3.Jinja2组件(Python的模板引擎库) 受控节点如果是Python 2.4 或 Python 2.5 ,则需额外安装Simplejson模块。到Python的2.6或以上版本,就则内置了Simplejson模块,不需要额外安装任何其它依赖。值得欣慰的是,目前主流的服务器上内置的Python版本...
https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.htmlformoreinformation. 先说结论 可以通过将以下设置添加到 Ansible 配置文件 (ansible.cfg) 来解决此问题。 vi/etc/ansible/ansible.cfg[defaults]interpreter_python=/usr/bin/python3 顺便说一下,Ansible 的版本是 2.8.8。 $ ans...
更新Ansible配置文件:在Ansible的配置文件ansible.cfg中,可以指定Python库的路径。可以尝试修改ansible.cfg文件中的ansible_python_interpreter配置项,将其指定为正确的Python解释器路径。 检查Ansible版本兼容性:有时候,新版本的Ansible可能与某些Python库存在兼容性问题。可以尝试降低Ansible版本,或者查看Ansible官方文档中关于Py...
{"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"}---退出自定义的ansible.cfg配置文件夹/root/myansible时执行ping主机组k8s---[root@k8s_master1 myansible]# cd .. //退出自定义配置文件夹[root@k8s_master1 ~]# ansible k8s -m ping[WARNING]: Could not...
ansible_python_interpreter:远程主机上的python解释器路径。默认为/usr/bin/python。 ansible_*_interpreter:使用什么解释器。例如,sh、bash、awk、sed、expect、ruby等等。 其中有几个参数可以在配置文件ansible.cfg中指定,但指定的指令不太一样,以下是对应的配置项: ...
1、每次执行命令的时候加个参数,跳过这个就不报错了。 -e "ansible_python_interpreter=auto_legacy_silent" ansible -ihosts_list app -e "ansible_python_interpreter=auto_legacy_silent" -m ping 2、永久解决方法就是: 解决办法: vim /etc/ansible/ansible.cfg ...
---在自定义的ansible.cfg配置文件夹/root/myansible中执行ping主机组k8s---[root@k8s_master1 myansible]# ansible k8s-m ping k8s_node2|SUCCESS=>{"ansible_facts":{"discovered_interpreter_python":"/usr/bin/python"},"changed":false,"ping":"pong"}k8s_node1|SUCCESS=>{"ansible_facts":{"discov...
[root@192-168-199-121 ~]# ansible 192.168.199.99 -m ping192.168.199.99 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"} 执行ps -ef能观察到,我们第一次连接完后,ssh 并没有断开,有一个背景执行的长链接,他实际上是一...