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
7deb8bbd
Commit
7deb8bbd
authored
Sep 12, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworking how includes within handlers are run
Fixes #12238
parent
c9860000
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
58 deletions
+68
-58
lib/ansible/plugins/strategies/__init__.py
+68
-58
No files found.
lib/ansible/plugins/strategies/__init__.py
View file @
7deb8bbd
...
@@ -464,64 +464,74 @@ class StrategyBase:
...
@@ -464,64 +464,74 @@ class StrategyBase:
# but this may take some work in the iterator and gets tricky when
# but this may take some work in the iterator and gets tricky when
# we consider the ability of meta tasks to flush handlers
# we consider the ability of meta tasks to flush handlers
for
handler
in
handler_block
.
block
:
for
handler
in
handler_block
.
block
:
handler_name
=
handler
.
get_name
()
should_run
=
handler
.
get_name
()
in
self
.
_notified_handlers
and
len
(
self
.
_notified_handlers
[
handler
.
get_name
()])
if
handler_name
in
self
.
_notified_handlers
and
len
(
self
.
_notified_handlers
[
handler_name
]):
if
should_run
:
# FIXME: need to use iterator.get_failed_hosts() instead?
result
=
self
.
_do_handler_run
(
handler
,
iterator
=
iterator
,
play_context
=
play_context
)
#if not len(self.get_hosts_remaining(iterator._play)):
if
not
result
:
# self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
break
# result = False
return
result
# break
self
.
_tqm
.
send_callback
(
'v2_playbook_on_handler_task_start'
,
handler
)
def
_do_handler_run
(
self
,
handler
,
iterator
,
play_context
,
notified_hosts
=
None
):
host_results
=
[]
for
host
in
self
.
_notified_handlers
[
handler_name
]:
# FIXME: need to use iterator.get_failed_hosts() instead?
if
not
handler
.
has_triggered
(
host
)
and
(
host
.
name
not
in
self
.
_tqm
.
_failed_hosts
or
play_context
.
force_handlers
):
#if not len(self.get_hosts_remaining(iterator._play)):
task_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
iterator
.
_play
,
host
=
host
,
task
=
handler
)
# self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
task_vars
=
self
.
add_tqm_variables
(
task_vars
,
play
=
iterator
.
_play
)
# result = False
self
.
_queue_task
(
host
,
handler
,
task_vars
,
play_context
)
# break
#handler.flag_for_host(host)
self
.
_tqm
.
send_callback
(
'v2_playbook_on_handler_task_start'
,
handler
)
results
=
self
.
_process_pending_results
(
iterator
)
host_results
.
extend
(
results
)
if
notified_hosts
is
None
:
results
=
self
.
_wait_on_pending_results
(
iterator
)
notified_hosts
=
self
.
_notified_handlers
[
handler
.
get_name
()]
host_results
.
extend
(
results
)
host_results
=
[]
# wipe the notification list
for
host
in
notified_hosts
:
self
.
_notified_handlers
[
handler_name
]
=
[]
if
not
handler
.
has_triggered
(
host
)
and
(
host
.
name
not
in
self
.
_tqm
.
_failed_hosts
or
play_context
.
force_handlers
):
task_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
iterator
.
_play
,
host
=
host
,
task
=
handler
)
try
:
task_vars
=
self
.
add_tqm_variables
(
task_vars
,
play
=
iterator
.
_play
)
included_files
=
IncludedFile
.
process_include_results
(
self
.
_queue_task
(
host
,
handler
,
task_vars
,
play_context
)
host_results
,
self
.
_tqm
,
# collect the results from the handler run
iterator
=
iterator
,
host_results
=
self
.
_wait_on_pending_results
(
iterator
)
loader
=
self
.
_loader
,
variable_manager
=
self
.
_variable_manager
try
:
)
included_files
=
IncludedFile
.
process_include_results
(
except
AnsibleError
as
e
:
host_results
,
return
False
self
.
_tqm
,
iterator
=
iterator
,
if
len
(
included_files
)
>
0
:
loader
=
self
.
_loader
,
for
included_file
in
included_files
:
variable_manager
=
self
.
_variable_manager
try
:
)
new_blocks
=
self
.
_load_included_file
(
included_file
,
iterator
=
iterator
,
is_handler
=
True
)
except
AnsibleError
as
e
:
# for every task in each block brought in by the include, add the list
return
False
# of hosts which included the file to the notified_handlers dict
for
block
in
new_blocks
:
result
=
True
for
task
in
block
.
block
:
if
len
(
included_files
)
>
0
:
if
task
.
name
in
self
.
_notified_handlers
:
for
included_file
in
included_files
:
for
host
in
included_file
.
_hosts
:
try
:
if
host
.
name
not
in
self
.
_notified_handlers
[
task
.
name
]:
new_blocks
=
self
.
_load_included_file
(
included_file
,
iterator
=
iterator
,
is_handler
=
True
)
self
.
_notified_handlers
[
task
.
name
]
.
append
(
host
)
# for every task in each block brought in by the include, add the list
else
:
# of hosts which included the file to the notified_handlers dict
self
.
_notified_handlers
[
task
.
name
]
=
included_file
.
_hosts
[:]
for
block
in
new_blocks
:
# and add the new blocks to the list of handler blocks
iterator
.
_play
.
handlers
.
append
(
block
)
handler_block
.
block
.
extend
(
block
.
block
)
for
task
in
block
.
block
:
#iterator._play.handlers.extend(new_blocks)
result
=
self
.
_do_handler_run
(
except
AnsibleError
as
e
:
handler
=
task
,
for
host
in
included_file
.
_hosts
:
iterator
=
iterator
,
iterator
.
mark_host_failed
(
host
)
play_context
=
play_context
,
self
.
_tqm
.
_failed_hosts
[
host
.
name
]
=
True
notified_hosts
=
included_file
.
_hosts
[:],
self
.
_display
.
warning
(
str
(
e
))
)
continue
if
not
result
:
self
.
_display
.
debug
(
"done running handlers, result is:
%
s"
%
result
)
break
except
AnsibleError
as
e
:
for
host
in
included_file
.
_hosts
:
iterator
.
mark_host_failed
(
host
)
self
.
_tqm
.
_failed_hosts
[
host
.
name
]
=
True
self
.
_display
.
warning
(
str
(
e
))
continue
# wipe the notification list
self
.
_notified_handlers
[
handler
.
get_name
()]
=
[]
self
.
_display
.
debug
(
"done running handlers, result is:
%
s"
%
result
)
return
result
return
result
def
_take_step
(
self
,
task
,
host
=
None
):
def
_take_step
(
self
,
task
,
host
=
None
):
...
...
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