2019-02-27 23:20:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
2019-03-11 14:14:06 +00:00
|
|
|
cleanup () {
|
|
|
|
files="shostlist.txt hostlist.txt"
|
|
|
|
for file in $files; do
|
|
|
|
if [[ -f "$file" ]]; then
|
|
|
|
rm -f "$file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-02-27 23:20:16 +00:00
|
|
|
for EXTRA in '{"inputlist": ["hostB", "hostA", "hostD", "hostC"]}' \
|
|
|
|
'{"myorder": "inventory", "inputlist": ["hostB", "hostA", "hostD", "hostC"]}' \
|
|
|
|
'{"myorder": "sorted", "inputlist": ["hostA", "hostB", "hostC", "hostD"]}' \
|
2019-03-11 14:14:06 +00:00
|
|
|
'{"myorder": "reverse_sorted", "inputlist": ["hostD", "hostC", "hostB", "hostA"]}' \
|
|
|
|
'{"myorder": "reverse_inventory", "inputlist": ["hostC", "hostD", "hostA", "hostB"]}' \
|
|
|
|
'{"myorder": "shuffle", "inputlist": ["hostC", "hostD", "hostA", "hostB"]}'
|
2019-02-27 23:20:16 +00:00
|
|
|
do
|
2019-03-11 14:14:06 +00:00
|
|
|
cleanup
|
|
|
|
ansible-playbook order.yml --forks 1 -i inventory -e "$EXTRA" "$@" || cleanup
|
2019-02-27 23:20:16 +00:00
|
|
|
done
|
2019-03-11 14:14:06 +00:00
|
|
|
cleanup
|