Skip to content

Commit

Permalink
Merge pull request #67 from ripienaar/66
Browse files Browse the repository at this point in the history
(#66) Allow nodes to fail during task::wait playbook
  • Loading branch information
ripienaar authored May 18, 2018
2 parents 4f024c8 + 7ea39ee commit 5cdc0d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions plans/tasks/wait.pp
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# Waits for a task to complete on all nodes
#
# A note about the use of `fail_ok`, this will instruct the system
# to not consider nodes that failed as part of the determination of
# completion and to assume the nodes that did respond well are representitive.
#
# This may have a undesired outcome where 1 completed node that is not
# failing can completely mask 999 failing nodes none of whome have completed.
# You need to use this flag with caution and be aware of the possible impact.
# It is therefor off by default.
#
# @param task_id The task ID to check
# @param nodes The nodes to check the task on
# @param tries How many times to perform the check before failing
# @param sleep How long to wait between checks
# @param fail_ok Allow some nodes to fail the actual check call
# @return [Boolean] indicates task completion
plan choria::tasks::wait (
String $task_id,
Choria::Nodes $nodes,
Integer $tries = 90,
Integer $sleep = 20
Integer $sleep = 20,
Boolean $fail_ok = false
) {
info("Waiting for task ${task_id} to complete on ${nodes.size} nodes")

Expand All @@ -19,12 +30,13 @@
"action" => "bolt_tasks.task_status",
"silent" => true,
"pre_sleep" => $sleep,
"fail_ok" => $fail_ok,
"properties" => {
"task_id" => $task_id
}
)

$completed = $results.map |$result| {
$completed = $results.ok_set.map |$result| {
$result["data"]["completed"]
}

Expand Down

0 comments on commit 5cdc0d9

Please sign in to comment.