mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
ensure we always have a basedir
This commit is contained in:
parent
1a43038bc2
commit
64220fcbcc
1 changed files with 5 additions and 4 deletions
|
@ -232,22 +232,23 @@ class VariableManager:
|
||||||
include_delegate_to=include_delegate_to,
|
include_delegate_to=include_delegate_to,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# default for all cases
|
||||||
|
basedirs = [self._loader.get_basedir()]
|
||||||
|
|
||||||
if play:
|
if play:
|
||||||
# first we compile any vars specified in defaults/main.yml
|
# first we compile any vars specified in defaults/main.yml
|
||||||
# for all roles within the specified play
|
# for all roles within the specified play
|
||||||
for role in play.get_roles():
|
for role in play.get_roles():
|
||||||
all_vars = combine_vars(all_vars, role.get_default_vars())
|
all_vars = combine_vars(all_vars, role.get_default_vars())
|
||||||
|
|
||||||
basedirs = []
|
|
||||||
if task:
|
if task:
|
||||||
# set basedirs
|
# set basedirs
|
||||||
if C.PLAYBOOK_VARS_ROOT == 'all': # should be default
|
if C.PLAYBOOK_VARS_ROOT == 'all': # should be default
|
||||||
basedirs = task.get_search_path()
|
basedirs = task.get_search_path()
|
||||||
elif C.PLAYBOOK_VARS_ROOT == 'top': # only option pre 2.3
|
|
||||||
basedirs = [self._loader.get_basedir()]
|
|
||||||
elif C.PLAYBOOK_VARS_ROOT in ('bottom', 'playbook_dir'): # only option in 2.4.0
|
elif C.PLAYBOOK_VARS_ROOT in ('bottom', 'playbook_dir'): # only option in 2.4.0
|
||||||
basedirs = [task.get_search_path()[0]]
|
basedirs = [task.get_search_path()[0]]
|
||||||
else:
|
elif C.PLAYBOOK_VARS_ROOT != 'top':
|
||||||
|
# preserves default basedirs, only option pre 2.3
|
||||||
raise AnsibleError('Unkown playbook vars logic: %s' % C.PLAYBOOK_VARS_ROOT)
|
raise AnsibleError('Unkown playbook vars logic: %s' % C.PLAYBOOK_VARS_ROOT)
|
||||||
|
|
||||||
# if we have a task in this context, and that task has a role, make
|
# if we have a task in this context, and that task has a role, make
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue