issue #106: 2.3.x compatible get_shebang-alike.

pull/193/head
David Wilson 8 years ago
parent e5723e4f5f
commit 822502125d

@ -166,20 +166,24 @@ class ScriptPlanner(BinaryPlanner):
Common functionality for script module planners -- handle interpreter Common functionality for script module planners -- handle interpreter
detection and rewrite. detection and rewrite.
""" """
def _rewrite_interpreter(self, interpreter, task_vars, templar):
key = u'ansible_%s_interpreter' % os.path.basename(interpreter).strip()
try:
return templar.template(task_vars[key].strip())
except KeyError:
return interpreter
def plan(self, invocation): def plan(self, invocation):
kwargs = super(ScriptPlanner, self).plan(invocation) kwargs = super(ScriptPlanner, self).plan(invocation)
interpreter, arg = parse_script_interpreter(invocation.module_source) interpreter, arg = parse_script_interpreter(invocation.module_source)
shebang, _ = module_common._get_shebang( return dict(kwargs,
interpreter=interpreter, interpreter_arg=arg,
task_vars=invocation.task_vars, interpreter=self._rewrite_interpreter(
templar=invocation.templar, interpreter=interpreter,
task_vars=invocation.task_vars,
templar=invocation.templar,
)
) )
if shebang:
interpreter = shebang[2:]
kwargs['interpreter'] = interpreter
kwargs['interpreter_arg'] = arg
return kwargs
class ReplacerPlanner(BinaryPlanner): class ReplacerPlanner(BinaryPlanner):

Loading…
Cancel
Save