|
|
@ -435,7 +435,7 @@ def _slurp(path):
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_shebang(interpreter, task_vars, args=tuple()):
|
|
|
|
def _get_shebang(interpreter, task_vars, templar, args=tuple()):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Note not stellar API:
|
|
|
|
Note not stellar API:
|
|
|
|
Returns None instead of always returning a shebang line. Doing it this
|
|
|
|
Returns None instead of always returning a shebang line. Doing it this
|
|
|
@ -448,7 +448,7 @@ def _get_shebang(interpreter, task_vars, args=tuple()):
|
|
|
|
if interpreter_config not in task_vars:
|
|
|
|
if interpreter_config not in task_vars:
|
|
|
|
return (None, interpreter)
|
|
|
|
return (None, interpreter)
|
|
|
|
|
|
|
|
|
|
|
|
interpreter = task_vars[interpreter_config].strip()
|
|
|
|
interpreter = templar.template(task_vars[interpreter_config].strip())
|
|
|
|
shebang = u'#!' + interpreter
|
|
|
|
shebang = u'#!' + interpreter
|
|
|
|
|
|
|
|
|
|
|
|
if args:
|
|
|
|
if args:
|
|
|
@ -598,7 +598,7 @@ def _is_binary(b_module_data):
|
|
|
|
return bool(start.translate(None, textchars))
|
|
|
|
return bool(start.translate(None, textchars))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression, async_timeout, become,
|
|
|
|
def _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, templar, module_compression, async_timeout, become,
|
|
|
|
become_method, become_user, become_password, environment):
|
|
|
|
become_method, become_user, become_password, environment):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Given the source of the module, convert it to a Jinja2 template to insert
|
|
|
|
Given the source of the module, convert it to a Jinja2 template to insert
|
|
|
@ -732,7 +732,7 @@ def _find_module_utils(module_name, b_module_data, module_path, module_args, tas
|
|
|
|
'Look at traceback for that process for debugging information.')
|
|
|
|
'Look at traceback for that process for debugging information.')
|
|
|
|
zipdata = to_text(zipdata, errors='surrogate_or_strict')
|
|
|
|
zipdata = to_text(zipdata, errors='surrogate_or_strict')
|
|
|
|
|
|
|
|
|
|
|
|
shebang, interpreter = _get_shebang(u'/usr/bin/python', task_vars)
|
|
|
|
shebang, interpreter = _get_shebang(u'/usr/bin/python', task_vars, templar)
|
|
|
|
if shebang is None:
|
|
|
|
if shebang is None:
|
|
|
|
shebang = u'#!/usr/bin/python'
|
|
|
|
shebang = u'#!/usr/bin/python'
|
|
|
|
|
|
|
|
|
|
|
@ -871,7 +871,7 @@ def _find_module_utils(module_name, b_module_data, module_path, module_args, tas
|
|
|
|
return (b_module_data, module_style, shebang)
|
|
|
|
return (b_module_data, module_style, shebang)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def modify_module(module_name, module_path, module_args, task_vars=None, module_compression='ZIP_STORED', async_timeout=0, become=False,
|
|
|
|
def modify_module(module_name, module_path, module_args, task_vars=None, templar=None, module_compression='ZIP_STORED', async_timeout=0, become=False,
|
|
|
|
become_method=None, become_user=None, become_password=None, environment=None):
|
|
|
|
become_method=None, become_user=None, become_password=None, environment=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Used to insert chunks of code into modules before transfer rather than
|
|
|
|
Used to insert chunks of code into modules before transfer rather than
|
|
|
@ -901,7 +901,7 @@ def modify_module(module_name, module_path, module_args, task_vars=None, module_
|
|
|
|
# read in the module source
|
|
|
|
# read in the module source
|
|
|
|
b_module_data = f.read()
|
|
|
|
b_module_data = f.read()
|
|
|
|
|
|
|
|
|
|
|
|
(b_module_data, module_style, shebang) = _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression,
|
|
|
|
(b_module_data, module_style, shebang) = _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, templar, module_compression,
|
|
|
|
async_timeout=async_timeout, become=become, become_method=become_method,
|
|
|
|
async_timeout=async_timeout, become=become, become_method=become_method,
|
|
|
|
become_user=become_user, become_password=become_password,
|
|
|
|
become_user=become_user, become_password=become_password,
|
|
|
|
environment=environment)
|
|
|
|
environment=environment)
|
|
|
@ -916,7 +916,7 @@ def modify_module(module_name, module_path, module_args, task_vars=None, module_
|
|
|
|
interpreter = args[0]
|
|
|
|
interpreter = args[0]
|
|
|
|
interpreter = to_bytes(interpreter)
|
|
|
|
interpreter = to_bytes(interpreter)
|
|
|
|
|
|
|
|
|
|
|
|
new_shebang = to_bytes(_get_shebang(interpreter, task_vars, args[1:])[0], errors='surrogate_or_strict', nonstring='passthru')
|
|
|
|
new_shebang = to_bytes(_get_shebang(interpreter, task_vars, templar, args[1:])[0], errors='surrogate_or_strict', nonstring='passthru')
|
|
|
|
if new_shebang:
|
|
|
|
if new_shebang:
|
|
|
|
lines[0] = shebang = new_shebang
|
|
|
|
lines[0] = shebang = new_shebang
|
|
|
|
|
|
|
|
|
|
|
|