Skip to content

Instantly share code, notes, and snippets.

@jctanner
Created May 24, 2019 13:51
Show Gist options
  • Save jctanner/938e4c578e2f3a3f12a7b9603ddac6fd to your computer and use it in GitHub Desktop.
Save jctanner/938e4c578e2f3a3f12a7b9603ddac6fd to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py
index 6a38edc..9b5f7b8 100644
--- a/lib/ansible/plugins/strategy/__init__.py
+++ b/lib/ansible/plugins/strategy/__init__.py
@@ -398,6 +398,8 @@ class StrategyBase:
cur_pass = 0
while True:
+ import q; q(cur_pass)
+ #import time; time.sleep(5)
try:
self._results_lock.acquire()
task_result = self._results.popleft()
@@ -613,6 +615,7 @@ class StrategyBase:
self._pending_results -= 1
if original_host.name in self._blocked_hosts:
+ import q; q('unblock', original_host.name)
del self._blocked_hosts[original_host.name]
# If this is a role task, mark the parent role as being run (if
diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py
index 3496032..ccc8055 100644
--- a/lib/ansible/plugins/strategy/linear.py
+++ b/lib/ansible/plugins/strategy/linear.py
@@ -210,6 +210,9 @@ class StrategyModule(StrategyBase):
try:
display.debug("getting the remaining hosts for this loop")
hosts_left = self.get_hosts_left(iterator)
+ thl = len(hosts_left)
+ import q; q(thl)
+
display.debug("done getting the remaining hosts for this loop")
# queue up this task for each host in the inventory
@@ -228,6 +231,11 @@ class StrategyModule(StrategyBase):
results = []
for (host, task) in host_tasks:
+ hkeys = list(self._blocked_hosts.keys())
+ blocked = [x for x in hkeys if self._blocked_hosts[x]]
+ tblk = len(blocked)
+ import q; q(tblk)
+
if not task:
continue
@@ -241,13 +249,17 @@ class StrategyModule(StrategyBase):
# sets BYPASS_HOST_LOOP to true, or if it has run_once enabled. If so, we
# will only send this task to the first host in the list.
+ '''
try:
action = action_loader.get(task.action, class_only=True)
except KeyError:
# we don't care here, because the action may simply not have a
# corresponding action plugin
action = None
+ '''
+ action = None
+ '''
# check to see if this task should be skipped, due to it being a member of a
# role which has already run (and whether that role allows duplicate execution)
if task._role and task._role.has_run(host):
@@ -256,10 +268,12 @@ class StrategyModule(StrategyBase):
if task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
display.debug("'%s' skipped because role has already run" % task)
continue
+ '''
if task.action == 'meta':
# for the linear strategy, we run meta tasks just once and for
# all hosts currently being iterated over rather than one host
+ import q; q('running meta')
results.extend(self._execute_meta(task, play_context, iterator, host))
if task.args.get('_raw_params', None) not in ('noop', 'reset_connection', 'end_host'):
run_once = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment