summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/lookup_sequence
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
commita453ac31f3428614cceb99027f8efbdb9258a40b (patch)
treef61f87408f32a8511cbd91799f9cececb53e0374 /test/integration/targets/lookup_sequence
parentInitial commit. (diff)
downloadansible-upstream.tar.xz
ansible-upstream.zip
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/lookup_sequence')
-rw-r--r--test/integration/targets/lookup_sequence/aliases3
-rw-r--r--test/integration/targets/lookup_sequence/tasks/main.yml63
2 files changed, 66 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_sequence/aliases b/test/integration/targets/lookup_sequence/aliases
new file mode 100644
index 00000000..bc987654
--- /dev/null
+++ b/test/integration/targets/lookup_sequence/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group2
+skip/aix
+skip/python2.6 # lookups are controller only, and we no longer support Python 2.6 on the controller
diff --git a/test/integration/targets/lookup_sequence/tasks/main.yml b/test/integration/targets/lookup_sequence/tasks/main.yml
new file mode 100644
index 00000000..72181a42
--- /dev/null
+++ b/test/integration/targets/lookup_sequence/tasks/main.yml
@@ -0,0 +1,63 @@
+- name: test with_sequence
+ set_fact: "{{ 'x' + item }}={{ item }}"
+ with_sequence: start=0 end=3
+
+- name: test with_sequence backwards
+ set_fact: "{{ 'y' + item }}={{ item }}"
+ with_sequence: start=3 end=0 stride=-1
+
+- name: verify with_sequence
+ assert:
+ that:
+ - "x0 == '0'"
+ - "x1 == '1'"
+ - "x2 == '2'"
+ - "x3 == '3'"
+ - "y3 == '3'"
+ - "y2 == '2'"
+ - "y1 == '1'"
+ - "y0 == '0'"
+
+- name: test with_sequence not failing on count == 0
+ debug: msg='previously failed with backward counting error'
+ with_sequence: count=0
+ register: count_of_zero
+
+- name: test with_sequence does 1 when start == end
+ debug: msg='should run once'
+ with_sequence: start=1 end=1
+ register: start_equal_end
+
+- name: test with_sequence count 1
+ set_fact: "{{ 'x' + item }}={{ item }}"
+ with_sequence: count=1
+ register: count_of_one
+
+- assert:
+ that:
+ - start_equal_end is not skipped
+ - count_of_zero is skipped
+ - count_of_one is not skipped
+
+- name: test with_sequence shortcut syntax (end)
+ set_fact: "{{ 'ws_z_' + item }}={{ item }}"
+ with_sequence: '4'
+
+- name: test with_sequence shortcut syntax (start-end/stride)
+ set_fact: "{{ 'ws_z_' + item }}=stride_{{ item }}"
+ with_sequence: '2-6/2'
+
+- name: test with_sequence shortcut syntax (start-end:format)
+ set_fact: "{{ 'ws_z_' + item }}={{ item }}"
+ with_sequence: '7-8:host%02d'
+
+- name: verify with_sequence shortcut syntax
+ assert:
+ that:
+ - "ws_z_1 == '1'"
+ - "ws_z_2 == 'stride_2'"
+ - "ws_z_3 == '3'"
+ - "ws_z_4 == 'stride_4'"
+ - "ws_z_6 == 'stride_6'"
+ - "ws_z_host07 == 'host07'"
+ - "ws_z_host08 == 'host08'"