summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/lookup_indexed_items/tasks/main.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/lookup_indexed_items/tasks/main.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/lookup_indexed_items/tasks/main.yml')
-rw-r--r--test/integration/targets/lookup_indexed_items/tasks/main.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_indexed_items/tasks/main.yml b/test/integration/targets/lookup_indexed_items/tasks/main.yml
new file mode 100644
index 0000000..434fe0f
--- /dev/null
+++ b/test/integration/targets/lookup_indexed_items/tasks/main.yml
@@ -0,0 +1,32 @@
+- name: create unindexed list
+ shell: for i in $(seq 1 5); do echo "x" ; done;
+ register: list_data
+
+- name: create indexed list
+ set_fact: "{{ item[1] + item[0]|string }}=set"
+ with_indexed_items: "{{list_data.stdout_lines}}"
+
+- name: verify with_indexed_items result
+ assert:
+ that:
+ - "x0 == 'set'"
+ - "x1 == 'set'"
+ - "x2 == 'set'"
+ - "x3 == 'set'"
+ - "x4 == 'set'"
+
+- block:
+ - name: "EXPECTED FAILURE - test not a list"
+ debug:
+ msg: "{{ item.0 }} is {{ item.1 }}"
+ with_indexed_items:
+ "a": 1
+
+ - fail:
+ msg: "should not get here"
+
+ rescue:
+ - assert:
+ that:
+ - ansible_failed_task.name == "EXPECTED FAILURE - test not a list"
+ - ansible_failed_result.msg == "with_indexed_items expects a list"