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

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

    I found out that it's actually possible to have multiple plays in a single playbook, so my setup now contains a "dependency provisioning" play which runs on all hosts, and other plays for specific hosts. So no more pre_tasks.

    For example:

    - name: dependency provisioning
      hosts: all
      become: yes
      become_method: sudo
      gather_facts: false
      tasks:
        - name: install python2
          raw: sudo apt-get -y install python-simplejson
    
    - name: production
      hosts: production_host
      roles:
        - nginx
      tasks:
        - name: update apt cache
          apt: update_cache=yes cache_valid_time=3600
      # ....
    
    - name: staging
      hosts: staging_host
      roles:
        - nginx
      tasks:
        - name: update apt cache
          apt: update_cache=yes cache_valid_time=3600
      # ....
    

提交回复
热议问题