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
56d7f388
Commit
56d7f388
authored
Sep 09, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new level of vars to deal with set_fact/register precedence rules
parent
926f1272
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
lib/ansible/plugins/strategies/__init__.py
+3
-2
lib/ansible/vars/__init__.py
+12
-11
No files found.
lib/ansible/plugins/strategies/__init__.py
View file @
56d7f388
...
...
@@ -238,11 +238,12 @@ class StrategyBase:
elif
result
[
0
]
==
'register_host_var'
:
# essentially the same as 'set_host_var' below, however we
# never follow the delegate_to value for registered vars
# never follow the delegate_to value for registered vars and
# the variable goes in the fact_cache
host
=
result
[
1
]
var_name
=
result
[
2
]
var_value
=
result
[
3
]
self
.
_variable_manager
.
set_host_
variable
(
host
,
var_name
,
var_value
)
self
.
_variable_manager
.
set_host_
facts
(
host
,
{
var_name
:
var_value
}
)
elif
result
[
0
]
in
(
'set_host_var'
,
'set_host_facts'
):
host
=
result
[
1
]
...
...
lib/ansible/vars/__init__.py
View file @
56d7f388
...
...
@@ -48,14 +48,14 @@ class VariableManager:
def
__init__
(
self
):
self
.
_fact_cache
=
FactCache
()
self
.
_vars_cache
=
defaultdict
(
dict
)
self
.
_extra_vars
=
defaultdict
(
dict
)
self
.
_host_vars_files
=
defaultdict
(
dict
)
self
.
_fact_cache
=
FactCache
()
self
.
_nonpersistent_fact_cache
=
defaultdict
(
dict
)
self
.
_vars_cache
=
defaultdict
(
dict
)
self
.
_extra_vars
=
defaultdict
(
dict
)
self
.
_host_vars_files
=
defaultdict
(
dict
)
self
.
_group_vars_files
=
defaultdict
(
dict
)
self
.
_inventory
=
None
self
.
_omit_token
=
'__omit_place_holder__
%
s'
%
sha1
(
os
.
urandom
(
64
))
.
hexdigest
()
self
.
_inventory
=
None
self
.
_omit_token
=
'__omit_place_holder__
%
s'
%
sha1
(
os
.
urandom
(
64
))
.
hexdigest
()
def
_get_cache_entry
(
self
,
play
=
None
,
host
=
None
,
task
=
None
):
play_id
=
"NONE"
...
...
@@ -179,13 +179,14 @@ class VariableManager:
for
item
in
data
:
all_vars
=
combine_vars
(
all_vars
,
item
)
# finally, the facts cache for this host, if it exists
# finally, the facts cache
s
for this host, if it exists
try
:
host_facts
=
self
.
_fact_cache
.
get
(
host
.
name
,
dict
())
for
k
in
host_facts
.
keys
():
if
host_facts
[
k
]
is
not
None
and
not
isinstance
(
host_facts
[
k
],
UnsafeProxy
):
host_facts
[
k
]
=
UnsafeProxy
(
host_facts
[
k
])
all_vars
=
combine_vars
(
all_vars
,
host_facts
)
all_vars
=
combine_vars
(
all_vars
,
self
.
_nonpersistent_fact_cache
.
get
(
host
.
name
,
dict
()))
except
KeyError
:
pass
...
...
@@ -370,12 +371,12 @@ class VariableManager:
assert
isinstance
(
facts
,
dict
)
if
host
.
name
not
in
self
.
_fact_cache
:
self
.
_fact_cache
[
host
.
name
]
=
facts
self
.
_
nonpersistent_
fact_cache
[
host
.
name
]
=
facts
else
:
try
:
self
.
_fact_cache
[
host
.
name
]
.
update
(
facts
)
self
.
_
nonpersistent_
fact_cache
[
host
.
name
]
.
update
(
facts
)
except
KeyError
:
self
.
_fact_cache
[
host
.
name
]
=
facts
self
.
_
nonpersistent_
fact_cache
[
host
.
name
]
=
facts
def
set_host_variable
(
self
,
host
,
varname
,
value
):
'''
...
...
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