解决在Ubuntu18.04版本遇到的python问题

Ubuntu18.04上用Ansible找不到Python路径.

由于Ubuntu默认是使用的Python3.6.7版本, 默认的命令是python3, 所以导致Ansible无法在客户端运行.

错误提示为

k8s-node03 | FAILED! => { “changed”: false, “module_stderr”: “Shared connection to 10.11.1.213 closed.\r\n”, “module_stdout”: “/bin/sh: 1: /usr/bin/python: not found\r\n”, “msg”: “The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error”, “rc”: 127 }

解决的办法有两种
  • python3版本创建个软连接

    1
    $ sudo ln -sf /usr/bin/python3 /usr/bin/python
  • 安装python2

    1
    $ sudo apt install python