Skip to content

Commit 3184436

Browse files
committed
skip_next_task method was added
1 parent ab96117 commit 3184436

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = cotea
3-
version = 1.3.13
3+
version = 1.3.14
44
author = David Badalyan
55
author_email = [email protected]
66
description = Tool that provides Python API to run Ansible programmatically.

src/cotea/runner.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,9 @@ def add_var_as_extra_var(self, new_var_name, value):
429429

430430

431431
def get_stats(self):
432-
return self.play_wrp.custom_stats
432+
return self.play_wrp.custom_stats
433+
434+
435+
def skip_next_task(self):
436+
skipped_task_name = self.task_wrp.skip_next_task()
437+
return skipped_task_name

src/cotea/wrappers/get_next_task_wrapper.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,22 @@ def get_prev_task_name(self):
210210

211211

212212
def skip_next_task(self):
213+
skipped_tasks = []
213214
for host in self.hosts_left:
214-
self.ansible_iterator.get_next_task_for_host(host)
215+
host_state_block_and_task = self.play_iterator.get_next_task_for_host(host)
216+
skipped_task = host_state_block_and_task[len(host_state_block_and_task) - 1]
217+
skipped_tasks.append(skipped_task)
218+
219+
skipped_task_name = ""
220+
221+
if len(skipped_tasks) > 0:
222+
# task should be tha same on all hosts
223+
task = skipped_tasks[0]
224+
225+
if hasattr(task, "get_name"):
226+
skipped_task_name = str(task.get_name())
227+
228+
return skipped_task_name
215229

216230

217231
def dont_add_last_task_after_new(self):

0 commit comments

Comments
 (0)