|
|
|
@ -30,6 +30,7 @@ import subprocess
|
|
|
|
|
import datetime
|
|
|
|
|
import pwd
|
|
|
|
|
import ast
|
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
|
|
class Globals(object):
|
|
|
|
|
|
|
|
|
@ -304,6 +305,7 @@ def legacy_varReplace(basedir, raw, vars, lookup_fatal=True, depth=0, expand_lis
|
|
|
|
|
|
|
|
|
|
def template(basedir, varname, vars, lookup_fatal=True, depth=0, expand_lists=True, convert_bare=False, fail_on_undefined=False, filter_fatal=True):
|
|
|
|
|
''' templates a data structure by traversing it and substituting for other data structures '''
|
|
|
|
|
from ansible import utils
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if convert_bare and isinstance(varname, basestring):
|
|
|
|
@ -314,6 +316,12 @@ def template(basedir, varname, vars, lookup_fatal=True, depth=0, expand_lists=Tr
|
|
|
|
|
if isinstance(varname, basestring):
|
|
|
|
|
if '{{' in varname or '{%' in varname:
|
|
|
|
|
varname = template_from_string(basedir, varname, vars, fail_on_undefined)
|
|
|
|
|
|
|
|
|
|
if (varname.startswith("{") and not varname.startswith("{{")) or varname.startswith("["):
|
|
|
|
|
eval_results = utils.safe_eval(varname, locals=vars, include_exceptions=True)
|
|
|
|
|
if eval_results[1] is None:
|
|
|
|
|
varname = eval_results[0]
|
|
|
|
|
|
|
|
|
|
if not '$' in varname:
|
|
|
|
|
return varname
|
|
|
|
|
|
|
|
|
|