diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/include_import/run_once/playbook.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream/2.14.3.tar.xz ansible-core-upstream/2.14.3.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test/integration/targets/include_import/run_once/playbook.yml | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/integration/targets/include_import/run_once/playbook.yml b/test/integration/targets/include_import/run_once/playbook.yml new file mode 100644 index 0000000..cc1e265 --- /dev/null +++ b/test/integration/targets/include_import/run_once/playbook.yml @@ -0,0 +1,61 @@ +# This playbook exists to document the behavior of how run_once when +# applied to a dynamic include works +# +# As with other uses of keywords on dynamic includes, it only affects the include. +# In this case it causes the include to only be processed for ansible_play_hosts[0] +# which has the side effect of only running the tasks on ansible_play_hosts[0] +# and would only delegate facts of the include itself, not the tasks contained within + +- hosts: localhost + gather_facts: false + tasks: + - add_host: + name: "{{ item }}" + ansible_connection: local + groups: + - all + loop: + - localhost0 + - localhost1 + + - add_host: + name: "{{ item }}" + groups: + - testing + ansible_connection: local + loop: + - localhost2 + - localhost3 + +- hosts: all:!testing + gather_facts: false + vars: + lola: untouched + tasks: + - include_tasks: + file: include_me.yml + apply: + run_once: true + run_once: true + + - assert: + that: + - lola == 'wiseman' + +- hosts: testing + gather_facts: false + vars: + lola: untouched + tasks: + - include_tasks: include_me.yml + run_once: true + + - assert: + that: + - lola == 'wiseman' + when: inventory_hostname == ansible_play_hosts[0] + + - assert: + that: + - lola == 'untouched' + when: inventory_hostname != ansible_play_hosts[0] |