1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

add option to ignore $legacy variable style substitution

This commit is contained in:
Matt Coddington 2013-05-06 09:48:52 -04:00 committed by Michael DeHaan
parent 67e67bca1f
commit 542eeeb5d6
3 changed files with 13 additions and 0 deletions

View file

@ -102,6 +102,13 @@ sudo_exe=sudo
# #
# hash_behaviour=replace # hash_behaviour=replace
# How to handle variable replacement - as of 1.2, Jinja2 variable syntax is
# preferred, but we still support the old $variable replacement too.
# If you change legacy_playbook_variables to no then Ansible will no longer
# try to do replacement on $variable style variables.
#
# legacy_playbook_variables=yes
# if you need to use jinja2 extensions, you can list them here # if you need to use jinja2 extensions, you can list them here
# use a coma to separate extensions, e.g. : # use a coma to separate extensions, e.g. :
# jinja2_extensions=jinja2.ext.do,jinja2.ext.i18n # jinja2_extensions=jinja2.ext.do,jinja2.ext.i18n

View file

@ -94,6 +94,7 @@ DEFAULT_KEEP_REMOTE_FILES = get_config(p, DEFAULTS, 'keep_remote_files', 'ANSIBL
DEFAULT_SUDO_EXE = get_config(p, DEFAULTS, 'sudo_exe', 'ANSIBLE_SUDO_EXE', 'sudo') DEFAULT_SUDO_EXE = get_config(p, DEFAULTS, 'sudo_exe', 'ANSIBLE_SUDO_EXE', 'sudo')
DEFAULT_SUDO_FLAGS = get_config(p, DEFAULTS, 'sudo_flags', 'ANSIBLE_SUDO_FLAGS', '-H') DEFAULT_SUDO_FLAGS = get_config(p, DEFAULTS, 'sudo_flags', 'ANSIBLE_SUDO_FLAGS', '-H')
DEFAULT_HASH_BEHAVIOUR = get_config(p, DEFAULTS, 'hash_behaviour', 'ANSIBLE_HASH_BEHAVIOUR', 'replace') DEFAULT_HASH_BEHAVIOUR = get_config(p, DEFAULTS, 'hash_behaviour', 'ANSIBLE_HASH_BEHAVIOUR', 'replace')
DEFAULT_LEGACY_PLAYBOOK_VARIABLES = get_config(p, DEFAULTS, 'legacy_playbook_variables', 'ANSIBLE_LEGACY_PLAYBOOK_VARIABLES', 'yes')
DEFAULT_JINJA2_EXTENSIONS = get_config(p, DEFAULTS, 'jinja2_extensions', 'ANSIBLE_JINJA2_EXTENSIONS', None) DEFAULT_JINJA2_EXTENSIONS = get_config(p, DEFAULTS, 'jinja2_extensions', 'ANSIBLE_JINJA2_EXTENSIONS', None)
DEFAULT_EXECUTABLE = get_config(p, DEFAULTS, 'executable', 'ANSIBLE_EXECUTABLE', '/bin/sh') DEFAULT_EXECUTABLE = get_config(p, DEFAULTS, 'executable', 'ANSIBLE_EXECUTABLE', '/bin/sh')

View file

@ -142,6 +142,11 @@ def _legacy_varFind(basedir, text, vars, lookup_fatal, depth, expand_lists):
original data in the caller. original data in the caller.
''' '''
# short circuit this whole function if we have specified we don't want
# legacy var replacement
if C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES == 'no':
return None
start = text.find("$") start = text.find("$")
if start == -1: if start == -1:
return None return None