diff options
Diffstat (limited to 'test/integration/targets/loop_control')
-rw-r--r-- | test/integration/targets/loop_control/aliases | 2 | ||||
-rw-r--r-- | test/integration/targets/loop_control/extended.yml | 23 | ||||
-rw-r--r-- | test/integration/targets/loop_control/inner.yml | 9 | ||||
-rw-r--r-- | test/integration/targets/loop_control/label.yml | 23 | ||||
-rwxr-xr-x | test/integration/targets/loop_control/runme.sh | 12 |
5 files changed, 69 insertions, 0 deletions
diff --git a/test/integration/targets/loop_control/aliases b/test/integration/targets/loop_control/aliases new file mode 100644 index 0000000..498fedd --- /dev/null +++ b/test/integration/targets/loop_control/aliases @@ -0,0 +1,2 @@ +shippable/posix/group4 +context/controller diff --git a/test/integration/targets/loop_control/extended.yml b/test/integration/targets/loop_control/extended.yml new file mode 100644 index 0000000..3467d32 --- /dev/null +++ b/test/integration/targets/loop_control/extended.yml @@ -0,0 +1,23 @@ +- name: loop_control/extended/include https://github.com/ansible/ansible/issues/61218 + hosts: localhost + gather_facts: false + tasks: + - name: loop on an include + include_tasks: inner.yml + loop: + - first + - second + - third + loop_control: + extended: yes + + - debug: + var: ansible_loop + loop: + - first + - second + - third + loop_control: + extended: yes + extended_allitems: no + failed_when: ansible_loop.allitems is defined diff --git a/test/integration/targets/loop_control/inner.yml b/test/integration/targets/loop_control/inner.yml new file mode 100644 index 0000000..1c286fa --- /dev/null +++ b/test/integration/targets/loop_control/inner.yml @@ -0,0 +1,9 @@ +- name: assert ansible_loop variables in include_tasks + assert: + that: + - ansible_loop.index == ansible_loop.index0 + 1 + - ansible_loop.revindex == ansible_loop.revindex0 + 1 + - ansible_loop.first == {{ ansible_loop.index == 1 }} + - ansible_loop.last == {{ ansible_loop.index == ansible_loop.length }} + - ansible_loop.length == 3 + - ansible_loop.allitems|join(',') == 'first,second,third' diff --git a/test/integration/targets/loop_control/label.yml b/test/integration/targets/loop_control/label.yml new file mode 100644 index 0000000..5ac85fd --- /dev/null +++ b/test/integration/targets/loop_control/label.yml @@ -0,0 +1,23 @@ +- name: loop_control/label https://github.com/ansible/ansible/pull/36430 + hosts: localhost + gather_facts: false + tasks: + - set_fact: + loopthis: + - name: foo + label: foo_label + - name: bar + label: bar_label + + - name: check that item label is updated each iteration + debug: + msg: "{{ looped_var.name }}" + with_items: "{{ loopthis }}" + loop_control: + loop_var: looped_var + label: "looped_var {{ looped_var.label }}" +# +# - assert: +# that: +# - "output.results[0]['_ansible_item_label'] == 'looped_var foo_label'" +# - "output.results[1]['_ansible_item_label'] == 'looped_var bar_label'" diff --git a/test/integration/targets/loop_control/runme.sh b/test/integration/targets/loop_control/runme.sh new file mode 100755 index 0000000..af065ea --- /dev/null +++ b/test/integration/targets/loop_control/runme.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -eux + +# user output has: +#ok: [localhost] => (item=looped_var foo_label) => { +#ok: [localhost] => (item=looped_var bar_label) => { +MATCH='foo_label +bar_label' +[ "$(ansible-playbook label.yml "$@" |grep 'item='|sed -e 's/^.*(item=looped_var \(.*\)).*$/\1/')" == "${MATCH}" ] + +ansible-playbook extended.yml "$@" |