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
293dd38d
Commit
293dd38d
authored
Jul 07, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle assigning results to the delegated to host
parent
49a14805
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
lib/ansible/executor/process/result.py
+3
-2
lib/ansible/plugins/strategies/__init__.py
+27
-11
No files found.
lib/ansible/executor/process/result.py
View file @
293dd38d
...
...
@@ -150,11 +150,12 @@ class ResultProcess(multiprocessing.Process):
self
.
_send_result
((
'add_group'
,
result
.
_host
,
result_item
))
elif
'ansible_facts'
in
result_item
:
# if this task is registering facts, do that now
item
=
result_item
.
get
(
'item'
,
None
)
if
result
.
_task
.
action
in
(
'set_fact'
,
'include_vars'
):
for
(
key
,
value
)
in
result_item
[
'ansible_facts'
]
.
iteritems
():
self
.
_send_result
((
'set_host_var'
,
result
.
_host
,
key
,
value
))
self
.
_send_result
((
'set_host_var'
,
result
.
_host
,
result
.
_task
,
item
,
key
,
value
))
else
:
self
.
_send_result
((
'set_host_facts'
,
result
.
_host
,
result_item
[
'ansible_facts'
]))
self
.
_send_result
((
'set_host_facts'
,
result
.
_host
,
result
.
_task
,
item
,
result
_item
[
'ansible_facts'
]))
# finally, send the ok for this task
self
.
_send_result
((
'host_task_ok'
,
result
))
...
...
lib/ansible/plugins/strategies/__init__.py
View file @
293dd38d
...
...
@@ -30,6 +30,7 @@ from ansible.playbook.handler import Handler
from
ansible.playbook.helpers
import
load_list_of_blocks
from
ansible.playbook.role
import
ROLE_CACHE
,
hash_params
from
ansible.plugins
import
_basedirs
,
filter_loader
,
lookup_loader
,
module_loader
from
ansible.template
import
Templar
from
ansible.utils.debug
import
debug
...
...
@@ -222,16 +223,31 @@ class StrategyBase:
if
host
not
in
self
.
_notified_handlers
[
handler_name
]:
self
.
_notified_handlers
[
handler_name
]
.
append
(
host
)
elif
result
[
0
]
==
'set_host_var'
:
host
=
result
[
1
]
var_name
=
result
[
2
]
var_value
=
result
[
3
]
self
.
_variable_manager
.
set_host_variable
(
host
,
var_name
,
var_value
)
elif
result
[
0
]
==
'set_host_facts'
:
host
=
result
[
1
]
facts
=
result
[
2
]
self
.
_variable_manager
.
set_host_facts
(
host
,
facts
)
elif
result
[
0
]
in
(
'set_host_var'
,
'set_host_facts'
):
host
=
result
[
1
]
task
=
result
[
2
]
item
=
result
[
3
]
if
task
.
delegate_to
is
not
None
:
task_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
iterator
.
_play
,
host
=
host
,
task
=
task
)
task_vars
=
self
.
add_tqm_variables
(
task_vars
,
play
=
iterator
.
_play
)
if
item
is
not
None
:
task_vars
[
'item'
]
=
item
templar
=
Templar
(
loader
=
self
.
_loader
,
variables
=
task_vars
)
host_name
=
templar
.
template
(
task
.
delegate_to
)
target_host
=
self
.
_inventory
.
get_host
(
host_name
)
if
target_host
is
None
:
target_host
=
Host
(
name
=
host_name
)
else
:
target_host
=
host
if
result
[
0
]
==
'set_host_var'
:
var_name
=
result
[
4
]
var_value
=
result
[
5
]
self
.
_variable_manager
.
set_host_variable
(
target_host
,
var_name
,
var_value
)
elif
result
[
0
]
==
'set_host_facts'
:
facts
=
result
[
4
]
self
.
_variable_manager
.
set_host_facts
(
target_host
,
facts
)
else
:
raise
AnsibleError
(
"unknown result message received:
%
s"
%
result
[
0
])
...
...
@@ -267,7 +283,7 @@ class StrategyBase:
if
host_name
in
self
.
_inventory
.
_hosts_cache
:
new_host
=
self
.
_inventory
.
_hosts_cache
[
host_name
]
else
:
new_host
=
Host
(
host_name
)
new_host
=
Host
(
name
=
host_name
)
self
.
_inventory
.
_hosts_cache
[
host_name
]
=
new_host
allgroup
=
self
.
_inventory
.
get_group
(
'all'
)
...
...
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