File tree Expand file tree Collapse file tree 4 files changed +21
-5
lines changed
Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -493,12 +493,24 @@ def port(self):
493493 return self ._connection_option ('port' )
494494
495495 def python_path (self , rediscover_python = False ):
496- s = self ._connection .get_task_var ('ansible_python_interpreter' )
497- # #511, #536: executor/module_common.py::_get_shebang() hard-wires
498- # "/usr/bin/python" as the default interpreter path if no other
499- # interpreter is specified.
496+ # See also
497+ # - ansible_mitogen.connecton.Connection.get_task_var()
498+ try :
499+ delegated_vars = self ._task_vars ['ansible_delegated_vars' ]
500+ variables = delegated_vars [self ._connection .delegate_to_hostname ]
501+ except KeyError :
502+ variables = self ._task_vars
503+
504+ interpreter_python = C .config .get_config_value (
505+ 'INTERPRETER_PYTHON' , variables = variables ,
506+ )
507+
508+ if '{{' in interpreter_python or '{%' in interpreter_python :
509+ templar = self ._connection .templar
510+ interpreter_python = templar .template (interpreter_python )
511+
500512 return parse_python_path (
501- s ,
513+ interpreter_python ,
502514 task_vars = self ._task_vars ,
503515 action = self ._action ,
504516 rediscover_python = rediscover_python )
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ In progress (unreleased)
2727 with `meta: reset_connection `
2828* :gh:issue: `1083 ` :mod: `ansible_mitogen `: Templated connection timeout
2929 (e.g. ``ansible_timeout ``).
30+ * :gh:issue: `740 ` :mod: `ansible_mitogen `: Respect ``interpreter_python ``
31+ in ``ansible.cfg `` and ``ANSIBLE_PYTHON_INTERPRETER `` environment variable.
3032
3133
3234v0.3.19 (2024-12-02)
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ tt-host-key-checking ansible_host=localhost ansible_host_key_checking=
5050tt-password ansible_host =localhost ansible_password =" {{ 'has_sudo_nopw_password' | trim }}" ansible_user =mitogen__has_sudo_nopw
5151tt-port ansible_host =localhost ansible_password =has_sudo_nopw_password ansible_port =" {{ 22 | int }}" ansible_user =mitogen__has_sudo_nopw
5252tt-private-key-file ansible_host =localhost ansible_private_key_file =" {{ git_basedir }}/tests/data/docker/mitogen__has_sudo_pubkey.key" ansible_user =mitogen__has_sudo_pubkey
53+ tt-python-interpreter ansible_host =localhost ansible_password =has_sudo_nopw_password ansible_python_interpreter =" {{ ansible_playbook_python | trim }}" ansible_user =mitogen__has_sudo_nopw
5354tt-remote-user ansible_host =localhost ansible_password =has_sudo_nopw_password ansible_user =" {{ 'mitogen__has_sudo_nopw' | trim }}"
5455tt-ssh-executable ansible_host =localhost ansible_password =has_sudo_nopw_password ansible_ssh_executable =" {{ 'ssh' | trim }}" ansible_user =mitogen__has_sudo_nopw
5556tt-timeout ansible_host =localhost ansible_password =has_sudo_nopw_password ansible_timeout =" {{ 5 | int }}" ansible_user =mitogen__has_sudo_nopw
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ tt-host-key-checking ansible_host={{ tt.hostname }} ansible_host_key_c
8484tt-password ansible_host={{ tt.hostname }} ansible_password="{{ '{{' }} 'has_sudo_nopw_password' | trim {{ '}}' }}" ansible_port={{ tt.port }} ansible_python_interpreter={{ tt.python_path }} ansible_user=mitogen__has_sudo_nopw
8585tt-port ansible_host={{ tt.hostname }} ansible_password=has_sudo_nopw_password ansible_port="{{ '{{' }} {{ tt.port }} | int {{ '}}' }}" ansible_python_interpreter={{ tt.python_path }} ansible_user=mitogen__has_sudo_nopw
8686tt-private-key-file ansible_host={{ tt.hostname }} ansible_port={{ tt.port }} ansible_private_key_file="{{ '{{' }} git_basedir {{ '}}' }}/tests/data/docker/mitogen__has_sudo_pubkey.key" ansible_python_interpreter={{ tt.python_path }} ansible_user=mitogen__has_sudo_pubkey
87+ tt-python-interpreter ansible_host={{ tt.hostname }} ansible_port={{ tt.port }} ansible_password=has_sudo_nopw_password ansible_python_interpreter="{{ '{{' }} '{{ tt.python_path }}' | trim {{ '}}' }}" ansible_user=mitogen__has_sudo_nopw
8788tt-remote-user ansible_host={{ tt.hostname }} ansible_password=has_sudo_nopw_password ansible_port={{ tt.port }} ansible_python_interpreter={{ tt.python_path }} ansible_user="{{ '{{' }} 'mitogen__has_sudo_nopw' | trim {{ '}}' }}"
8889tt-ssh-executable ansible_host={{ tt.hostname }} ansible_password=has_sudo_nopw_password ansible_port={{ tt.port }} ansible_python_interpreter={{ tt.python_path }} ansible_ssh_executable="{{ '{{' }} 'ssh' | trim {{ '}}' }}" ansible_user=mitogen__has_sudo_nopw
8990tt-timeout ansible_host={{ tt.hostname }} ansible_password=has_sudo_nopw_password ansible_port={{ tt.port }} ansible_python_interpreter={{ tt.python_path }} ansible_timeout="{{ '{{' }} 5 | int {{ '}}' }}" ansible_user=mitogen__has_sudo_nopw
You can’t perform that action at this time.
0 commit comments