Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
313f26f8
Commit
313f26f8
authored
Sep 30, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with vars precedence from roles
Fixes #9219
parent
c6bfd05c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
+13
-5
lib/ansible/playbook/play.py
+1
-1
lib/ansible/runner/__init__.py
+10
-2
test/integration/roles/test_var_precedence_role1/tasks/main.yml
+1
-1
test/integration/roles/test_var_precedence_role2/tasks/main.yml
+1
-1
No files found.
lib/ansible/playbook/play.py
View file @
313f26f8
...
...
@@ -372,7 +372,7 @@ class Play(object):
# flush handlers after pre_tasks
new_tasks
.
append
(
dict
(
meta
=
'flush_handlers'
))
roles
=
self
.
_build_role_dependencies
(
roles
,
[],
self
.
vars
)
roles
=
self
.
_build_role_dependencies
(
roles
,
[],
{}
)
# give each role an uuid and
# make role_path available as variable to the task
...
...
lib/ansible/runner/__init__.py
View file @
313f26f8
...
...
@@ -600,6 +600,14 @@ class Runner(object):
module_vars_inject
=
utils
.
combine_vars
(
self
.
module_vars
,
module_vars_inject
)
module_vars
=
template
.
template
(
self
.
basedir
,
self
.
module_vars
,
module_vars_inject
)
# remove bad variables from the module vars, which may be in there due
# the way role declarations are specified in playbooks
if
'tags'
in
module_vars
:
del
module_vars
[
'tags'
]
if
'when'
in
module_vars
:
del
module_vars
[
'when'
]
# start building the dictionary of injected variables
inject
=
{}
# default vars are the lowest priority
...
...
@@ -608,10 +616,10 @@ class Runner(object):
inject
=
utils
.
combine_vars
(
inject
,
host_variables
)
# then the setup_cache which contains facts gathered
inject
=
utils
.
combine_vars
(
inject
,
self
.
setup_cache
.
get
(
host
,
{}))
# then come the module variables
inject
=
utils
.
combine_vars
(
inject
,
module_vars
)
# followed by vars (vars, vars_files, vars/main.yml)
inject
=
utils
.
combine_vars
(
inject
,
self
.
vars_cache
.
get
(
host
,
{}))
# then come the module variables
inject
=
utils
.
combine_vars
(
inject
,
module_vars
)
# and finally -e vars are the highest priority
inject
=
utils
.
combine_vars
(
inject
,
self
.
extra_vars
)
# and then special vars
...
...
test/integration/roles/test_var_precedence_role1/tasks/main.yml
View file @
313f26f8
...
...
@@ -10,5 +10,5 @@
-
'
param_var
==
"param_var_role1"'
-
'
vars_var
==
"vars_var"'
-
'
vars_files_var
==
"vars_files_var"'
-
'
vars_files_var_role
==
"vars_files_var_role
3
"'
-
'
vars_files_var_role
==
"vars_files_var_role
1
"'
-
'
defaults_file_var_role1
==
"defaults_file_var_role1"'
test/integration/roles/test_var_precedence_role2/tasks/main.yml
View file @
313f26f8
...
...
@@ -10,5 +10,5 @@
-
'
param_var
==
"param_var_role2"'
-
'
vars_var
==
"vars_var"'
-
'
vars_files_var
==
"vars_files_var"'
-
'
vars_files_var_role
==
"vars_files_var_role
3
"'
-
'
vars_files_var_role
==
"vars_files_var_role
2
"'
-
'
defaults_file_var_role2
==
"overridden
by
role
vars"'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment