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

后端 未结 19 1102
执念已碎
执念已碎 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:58

    I stumbled upon this error running ansible on Ubuntu 15.10 server, because it ships with Python 3.4.3 and ansible requires Python 2.

    This is how my provision.yml looks now:

    - hosts: my_app
      sudo: yes
      remote_user: root
      gather_facts: no
      pre_tasks:
        - name: 'install python2'
          raw: sudo apt-get -y install python
    
      tasks:
        - name: 'ensure user {{ project_name }} exists'
          user: name={{ project_name }} state=present
    
    • Don't forget the -y (says yes to all questions) option with apt-get (or raw module will get stuck silently)

    • gather_facts: no line is also critical (because we can't gather facts without python)

提交回复
热议问题