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
50448d68
Commit
50448d68
authored
Aug 26, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement max_fail_percentage and any_errors_fatal support
Fixes #11997
parent
af41ba92
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
lib/ansible/executor/playbook_executor.py
+17
-3
lib/ansible/executor/task_queue_manager.py
+4
-0
lib/ansible/playbook/task.py
+15
-0
No files found.
lib/ansible/executor/playbook_executor.py
View file @
50448d68
...
@@ -128,15 +128,29 @@ class PlaybookExecutor:
...
@@ -128,15 +128,29 @@ class PlaybookExecutor:
self
.
_tqm
.
send_callback
(
'v2_playbook_on_play_start'
,
new_play
)
self
.
_tqm
.
send_callback
(
'v2_playbook_on_play_start'
,
new_play
)
self
.
_tqm
.
send_callback
(
'v2_playbook_on_no_hosts_matched'
)
self
.
_tqm
.
send_callback
(
'v2_playbook_on_no_hosts_matched'
)
break
break
# restrict the inventory to the hosts in the serialized batch
# restrict the inventory to the hosts in the serialized batch
self
.
_inventory
.
restrict_to_hosts
(
batch
)
self
.
_inventory
.
restrict_to_hosts
(
batch
)
# and run it...
# and run it...
result
=
self
.
_tqm
.
run
(
play
=
play
)
result
=
self
.
_tqm
.
run
(
play
=
play
)
# if the last result wasn't zero, break out of the serial batch loop
if
result
!=
0
:
# check the number of failures here, to see if they're above the maximum
# failure percentage allowed, or if any errors are fatal. If either of those
# conditions are met, we break out, otherwise we only break out if the entire
# batch failed
failed_hosts_count
=
len
(
self
.
_tqm
.
_failed_hosts
)
+
len
(
self
.
_tqm
.
_unreachable_hosts
)
if
new_play
.
any_errors_fatal
and
failed_hosts_count
>
0
:
break
elif
new_play
.
max_fail_percentage
is
not
None
and
\
int
((
new_play
.
max_fail_percentage
)
/
100.0
*
len
(
batch
))
>
int
((
len
(
batch
)
-
failed_hosts_count
)
/
len
(
batch
)
*
100.0
):
break
break
elif
len
(
batch
)
==
failed_hosts_count
:
break
# clear the failed hosts dictionaires in the TQM for the next batch
self
.
_tqm
.
clear_failed_hosts
()
# if the last result wasn't zero, break out of the
play
loop
# if the last result wasn't zero, break out of the
serial batch
loop
if
result
!=
0
:
if
result
!=
0
:
break
break
...
...
lib/ansible/executor/task_queue_manager.py
View file @
50448d68
...
@@ -210,6 +210,10 @@ class TaskQueueManager:
...
@@ -210,6 +210,10 @@ class TaskQueueManager:
main_q
.
close
()
main_q
.
close
()
worker_prc
.
terminate
()
worker_prc
.
terminate
()
def
clear_failed_hosts
(
self
):
self
.
_failed_hosts
=
dict
()
self
.
_unreachable_hosts
=
dict
()
def
get_inventory
(
self
):
def
get_inventory
(
self
):
return
self
.
_inventory
return
self
.
_inventory
...
...
lib/ansible/playbook/task.py
View file @
50448d68
...
@@ -39,6 +39,13 @@ from ansible.playbook.taggable import Taggable
...
@@ -39,6 +39,13 @@ from ansible.playbook.taggable import Taggable
__all__
=
[
'Task'
]
__all__
=
[
'Task'
]
try
:
from
__main__
import
display
display
=
display
except
ImportError
:
from
ansible.utils.display
import
Display
display
=
Display
()
class
Task
(
Base
,
Conditional
,
Taggable
,
Become
):
class
Task
(
Base
,
Conditional
,
Taggable
,
Become
):
"""
"""
...
@@ -193,6 +200,14 @@ class Task(Base, Conditional, Taggable, Become):
...
@@ -193,6 +200,14 @@ class Task(Base, Conditional, Taggable, Become):
return
super
(
Task
,
self
)
.
preprocess_data
(
new_ds
)
return
super
(
Task
,
self
)
.
preprocess_data
(
new_ds
)
def
_load_any_errors_fatal
(
self
,
attr
,
value
):
'''
Exists only to show a deprecation warning, as this attribute is not valid
at the task level.
'''
display
.
deprecated
(
"Setting any_errors_fatal on a task is no longer supported. This should be set at the play level only"
)
return
None
def
post_validate
(
self
,
templar
):
def
post_validate
(
self
,
templar
):
'''
'''
Override of base class post_validate, to also do final validation on
Override of base class post_validate, to also do final validation on
...
...
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