From 3a2a1e054f983197546d11510a1c7eee1d21d134 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 27 Nov 2017 17:02:47 +0100 Subject: [PATCH] Fix include in loop when stategy=free (#33094) --- lib/ansible/executor/play_iterator.py | 2 +- .../includes/roles/test_includes_free/tasks/inner.yml | 2 ++ .../includes/roles/test_includes_free/tasks/main.yml | 6 ++++++ test/integration/targets/includes/test_include_free.yml | 9 +++++++++ test/integration/targets/includes/test_includes.yml | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml create mode 100644 test/integration/targets/includes/roles/test_includes_free/tasks/main.yml create mode 100644 test/integration/targets/includes/test_include_free.yml diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py index 158ed0d9b98..99b7285182a 100644 --- a/lib/ansible/executor/play_iterator.py +++ b/lib/ansible/executor/play_iterator.py @@ -431,7 +431,7 @@ class PlayIterator: # we're advancing blocks, so if this was an end-of-role block we # mark the current role complete - if block._eor and host.name in block._role._had_task_run and not in_child: + if block._eor and host.name in block._role._had_task_run and not in_child and not peek: block._role._completed[host.name] = True else: task = block.always[state.cur_always_task] diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml new file mode 100644 index 00000000000..d9c32f4f3dc --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml @@ -0,0 +1,2 @@ +- set_fact: + inner: "reached" diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml new file mode 100644 index 00000000000..7bc19faae1f --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml @@ -0,0 +1,6 @@ +- name: this needs to be here + debug: + msg: "hello" +- include: inner.yml + with_items: + - '1' diff --git a/test/integration/targets/includes/test_include_free.yml b/test/integration/targets/includes/test_include_free.yml new file mode 100644 index 00000000000..4cdc1bca50a --- /dev/null +++ b/test/integration/targets/includes/test_include_free.yml @@ -0,0 +1,9 @@ +- hosts: testhost + gather_facts: no + strategy: free + roles: + - test_includes_free + tasks: + - assert: + that: + - "inner == 'reached'" diff --git a/test/integration/targets/includes/test_includes.yml b/test/integration/targets/includes/test_includes.yml index d7303880f16..ebc4c1c2a68 100644 --- a/test/integration/targets/includes/test_includes.yml +++ b/test/integration/targets/includes/test_includes.yml @@ -1,3 +1,5 @@ - include: test_includes2.yml parameter1=asdf parameter2=jkl - include: test_includes3.yml + +- include: test_include_free.yml