mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Introduce ansible_python_interpreter variable.
This allows configuration of the correct python interpreter on the managed system.
This commit is contained in:
parent
57a34d914f
commit
1f63c47738
1 changed files with 13 additions and 1 deletions
|
@ -721,7 +721,19 @@ class Runner(object):
|
||||||
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
||||||
|
|
||||||
out_path = tmp + module
|
out_path = tmp + module
|
||||||
|
|
||||||
|
# use the correct python interpreter for the host
|
||||||
|
host_variables = self.inventory.get_variables(conn.host)
|
||||||
|
if 'ansible_python_interpreter' in host_variables:
|
||||||
|
interpreter = host_variables['ansible_python_interpreter']
|
||||||
|
with open(in_path) as f:
|
||||||
|
module_lines = f.readlines()
|
||||||
|
if '#!' and 'python' in module_lines[0]:
|
||||||
|
module_lines[0] = "#!%s" % interpreter
|
||||||
|
self._transfer_str(conn, tmp, module, '\n'.join(module_lines))
|
||||||
|
else:
|
||||||
conn.put_file(in_path, out_path)
|
conn.put_file(in_path, out_path)
|
||||||
|
|
||||||
return out_path
|
return out_path
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
Loading…
Reference in a new issue