Ansible:委派给时更改python interpeter

pka*_*mol 1 python ansible

我正在主持人A上播放一些剧本。

还有其他一些需要在主机B(Ubuntu 16.04)上运行的游戏,但是仅与python3一起提供,因此以下任务

- name: db_config -> Create MY database
  mysql_db:
    ...create some db
  delegate_to: "{{ ec2_instance_ip }}"
Run Code Online (Sandbox Code Playgroud)

失败:

失败:[localhost-> 33.99.123.88] => {“已更改”:false,“ module_stderr”:“与33.99.123.88的共享连接已关闭。\ r \ n”,“ module_stdout”:“ / bin / sh:1: / usr / bin / python:找不到\ r \ n“,” msg“:”模块失败“,” rc“:127}

我如何才能像上面的那样更改委派任务的python interpeter ?

tec*_*raf 6

只需添加ansible_python_interpreter到任务中:

- name: db_config -> Create MY database
  mysql_db:
    ...create some db
  delegate_to: "{{ ec2_instance_ip }}"
  vars:
    ansible_python_interpreter: /path/to/python
Run Code Online (Sandbox Code Playgroud)