Fix executing includes in the free strategy (#75649)

Fixes #75642
pull/75950/head
Martin Krizek 3 years ago committed by GitHub
parent 7a28246248
commit b1211429d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix executing includes in the always section in the free strategy (https://github.com/ansible/ansible/issues/75642)

@ -120,17 +120,19 @@ class StrategyModule(StrategyBase):
(state, task) = iterator.get_next_task_for_host(host, peek=True)
display.debug("free host state: %s" % state, host=host_name)
display.debug("free host task: %s" % task, host=host_name)
if host_name not in self._tqm._unreachable_hosts and task:
# check if there is work to do, either there is a task or the host is still blocked which could
# mean that it is processing an include task and after its result is processed there might be
# more tasks to run
if (task or self._blocked_hosts.get(host_name, False)) and not self._tqm._unreachable_hosts.get(host_name, False):
display.debug("this host has work to do", host=host_name)
# set the flag so the outer loop knows we've still found
# some work which needs to be done
work_to_do = True
display.debug("this host has work to do", host=host_name)
if not self._tqm._unreachable_hosts.get(host_name, False) and task:
# check to see if this host is blocked (still executing a previous task)
if (host_name not in self._blocked_hosts or not self._blocked_hosts[host_name]):
if not self._blocked_hosts.get(host_name, False):
display.debug("getting variables", host=host_name)
task_vars = self._variable_manager.get_vars(play=iterator._play, host=host, task=task,
_hosts=self._hosts_cache,

@ -0,0 +1,2 @@
[local]
testhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"

@ -0,0 +1,2 @@
- debug:
msg: "INCLUDED TASK EXECUTED"

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_STRATEGY=free
set +e
result="$(ansible-playbook test_last_include_in_always.yml -i inventory "$@" 2>&1)"
set -e
grep -q "INCLUDED TASK EXECUTED" <<< "$result"

@ -0,0 +1,9 @@
- hosts: testhost
gather_facts: false
strategy: free
tasks:
- block:
- name: EXPECTED FAILURE
fail:
always:
- include_tasks: last_include_tasks.yml
Loading…
Cancel
Save