ansible 连接错误

FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 52.82.37.16 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
"msg": "MODULE FAILURE",
"rc": 127
}

问题是remote机器的默认python版本为python3。
这里有两个可用的办法:

1. -e添加变量

ansible_python_interpreter这个变量设置了使用哪个版本的python。

ansible all -m ping -e ansible_python_interpreter=/usr/bin/python3 -u xxx

但是缺点也很明显,每次都要加上这个特别麻烦,来看第二个方法,一步到位。

2. 把变量添加到hosts

找到/etc/ansible

sudo vi hosts

加上52.82.37.88 ansible_python_interpreter=/usr/bin/python3
远程主机ip加设置变量。
保存退出就可以了。
以上!

推荐阅读更多精彩内容

  • 1. Python的hello-world: print ("Hello, Python!")、 完了 摇就完事儿...
    LunarShade阅读 1,065评论 0 0
  • 一、初识ansible 1、ansible是新出现的自动化运维工具 ansible是一个配置管理和应用部署工具,基...
    清风徐来_简阅读 2,290评论 0 15
  • 1)安装2)常用模块3)inventory4)playbook(role\tag\template)5) yaml...
    秦记阅读 3,565评论 2 5
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,233评论 0 3
  • 一天晚上,一群游牧部落的牧民正准备安营扎寨。休息的时候,忽然被一束耀眼的光芒所笼罩,他们知道神就要出现了。因此,他...
    Nina_妮娜阅读 24评论 0 0