diff options
Diffstat (limited to 'test/integration/targets/order')
-rw-r--r-- | test/integration/targets/order/aliases | 2 | ||||
-rw-r--r-- | test/integration/targets/order/inventory | 9 | ||||
-rw-r--r-- | test/integration/targets/order/order.yml | 39 | ||||
-rwxr-xr-x | test/integration/targets/order/runme.sh | 24 |
4 files changed, 74 insertions, 0 deletions
diff --git a/test/integration/targets/order/aliases b/test/integration/targets/order/aliases new file mode 100644 index 0000000..8278ec8 --- /dev/null +++ b/test/integration/targets/order/aliases @@ -0,0 +1,2 @@ +shippable/posix/group3 +context/controller diff --git a/test/integration/targets/order/inventory b/test/integration/targets/order/inventory new file mode 100644 index 0000000..11f322a --- /dev/null +++ b/test/integration/targets/order/inventory @@ -0,0 +1,9 @@ +[incremental] +hostB +hostA +hostD +hostC + +[incremental:vars] +ansible_connection=local +ansible_python_interpreter='{{ansible_playbook_python}}' diff --git a/test/integration/targets/order/order.yml b/test/integration/targets/order/order.yml new file mode 100644 index 0000000..62176b1 --- /dev/null +++ b/test/integration/targets/order/order.yml @@ -0,0 +1,39 @@ +- name: just plain order + hosts: all + gather_facts: false + order: '{{ myorder | default("inventory") }}' + tasks: + - shell: "echo '{{ inventory_hostname }}' >> hostlist.txt" + +- name: with serial + hosts: all + gather_facts: false + serial: 1 + order: '{{ myorder | default("inventory")}}' + tasks: + - shell: "echo '{{ inventory_hostname }}' >> shostlist.txt" + +- name: ensure everything works + hosts: localhost + gather_facts: false + tasks: + - assert: + that: + - item.1 == hostlist[item.0] + - item.1 == shostlist[item.0] + loop: '{{ lookup("indexed_items", inputlist) }}' + vars: + hostlist: '{{ lookup("file", "hostlist.txt").splitlines() }}' + shostlist: '{{ lookup("file", "shostlist.txt").splitlines() }}' + when: myorder | default('inventory') != 'shuffle' + + - name: Assert that shuffle worked + assert: + that: + - item.1 != hostlist[item.0] or item.1 in hostlist + - item.1 != hostlist[item.0] or item.1 in hostlist + loop: '{{ lookup("indexed_items", inputlist) }}' + vars: + hostlist: '{{ lookup("file", "hostlist.txt").splitlines() }}' + shostlist: '{{ lookup("file", "shostlist.txt").splitlines() }}' + when: myorder | default('inventory') == 'shuffle' diff --git a/test/integration/targets/order/runme.sh b/test/integration/targets/order/runme.sh new file mode 100755 index 0000000..9a01c21 --- /dev/null +++ b/test/integration/targets/order/runme.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -eux + +cleanup () { + files="shostlist.txt hostlist.txt" + for file in $files; do + if [[ -f "$file" ]]; then + rm -f "$file" + fi + done +} + +for EXTRA in '{"inputlist": ["hostB", "hostA", "hostD", "hostC"]}' \ + '{"myorder": "inventory", "inputlist": ["hostB", "hostA", "hostD", "hostC"]}' \ + '{"myorder": "sorted", "inputlist": ["hostA", "hostB", "hostC", "hostD"]}' \ + '{"myorder": "reverse_sorted", "inputlist": ["hostD", "hostC", "hostB", "hostA"]}' \ + '{"myorder": "reverse_inventory", "inputlist": ["hostC", "hostD", "hostA", "hostB"]}' \ + '{"myorder": "shuffle", "inputlist": ["hostC", "hostD", "hostA", "hostB"]}' +do + cleanup + ansible-playbook order.yml --forks 1 -i inventory -e "$EXTRA" "$@" +done +cleanup |