Ansible fails with /bin/sh: 1: /usr/bin/python: not found

后端 未结 19 1098
执念已碎
执念已碎 2020-11-29 15:15

I\'m running into an error I\'ve never seen before. Here is the command and the error:

$ ansible-playbook create_api.yml

PLAY [straw] **********************         


        
19条回答
  •  野性不改
    2020-11-29 15:35

    By default, Ansible requires Python 2, however, Ansible 2.2+ can work with Python 3 as well.

    So either install Python 2 using the raw module, e.g.

    ansible localhost --sudo -m raw -a "yum install -y python2 python-simplejson"
    

    or set ansible_python_interpreter variable in the inventory file, like:

    [local]
    localhost ansible_python_interpreter="env python3"
    

    For Docker, you can add the following line:

    RUN printf '[local]\r\nlocalhost ansible_python_interpreter="env python3"\r\n' > /etc/ansible/hosts
    

    or run it as:

    ansible-playbook /ansible/provision.yml -e 'ansible_python_interpreter=/usr/bin/python3' -c local
    

提交回复
热议问题