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
19b78ced
Commit
19b78ced
authored
Sep 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abort a play when there are no more hosts in it.
parent
5846c1b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
lib/ansible/playbook/__init__.py
+24
-3
No files found.
lib/ansible/playbook/__init__.py
View file @
19b78ced
...
...
@@ -235,7 +235,14 @@ class PlayBook(object):
# if not polling, playbook requested fire and forget, so don't poll
results
=
self
.
_async_poll
(
poller
,
task
.
async_seconds
,
task
.
async_poll_interval
)
contacted
=
results
.
get
(
'contacted'
,{})
dark
=
results
.
get
(
'dark'
,
{})
self
.
inventory
.
lift_restriction
()
if
len
(
contacted
.
keys
())
==
0
and
len
(
dark
.
keys
())
==
0
:
return
None
return
results
# *****************************************************
...
...
@@ -247,14 +254,18 @@ class PlayBook(object):
# load up an appropriate ansible runner to run the task in parallel
results
=
self
.
_run_task_internal
(
task
)
# if no hosts are matched, carry on
hosts_remaining
=
True
if
results
is
None
:
hosts_remaining
=
False
results
=
{}
contacted
=
results
.
get
(
'contacted'
,
{})
self
.
stats
.
compute
(
results
,
ignore_errors
=
task
.
ignore_errors
)
# add facts to the global setup cache
for
host
,
result
in
results
[
'contacted'
]
.
iteritems
():
for
host
,
result
in
contacted
.
iteritems
():
facts
=
result
.
get
(
'ansible_facts'
,
{})
self
.
SETUP_CACHE
[
host
]
.
update
(
facts
)
if
task
.
register
:
...
...
@@ -269,6 +280,8 @@ class PlayBook(object):
for
handler_name
in
task
.
notify
:
self
.
_flag_handler
(
play
.
handlers
(),
utils
.
template
(
play
.
basedir
,
handler_name
,
task
.
module_vars
),
host
)
return
hosts_remaining
# *****************************************************
def
_flag_handler
(
self
,
handlers
,
handler_name
,
host
):
...
...
@@ -347,11 +360,16 @@ class PlayBook(object):
play_hosts
.
append
(
all_hosts
.
pop
())
serialized_batch
.
append
(
play_hosts
)
hosts_remaining
=
True
for
on_hosts
in
serialized_batch
:
self
.
inventory
.
also_restrict_to
(
on_hosts
)
for
task
in
play
.
tasks
():
if
not
hosts_remaining
:
continue
# only run the task if the requested tags match
should_run
=
False
for
x
in
self
.
only_tags
:
...
...
@@ -360,10 +378,13 @@ class PlayBook(object):
should_run
=
True
break
if
should_run
:
self
.
_run_task
(
play
,
task
,
False
)
if
not
self
.
_run_task
(
play
,
task
,
False
):
hosts_remaining
=
False
# run notify actions
for
handler
in
play
.
handlers
():
if
not
hosts_remaining
:
continue
if
len
(
handler
.
notified_by
)
>
0
:
self
.
inventory
.
restrict_to
(
handler
.
notified_by
)
self
.
_run_task
(
play
,
handler
,
True
)
...
...
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