Debian Codegraph @

test/integration/targets/hosts_field/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # Hosts in playbook has a list of strings consisting solely of digits
6 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
7 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
8 -t string_digit_host_in_list -v "$@" | tee test_hosts_field.out
9 grep 'Running on 42' test_hosts_field.out 2>&1
10 test "$(grep -c 'ok=1' test_hosts_field.out)" = 1
11
12 # Hosts taken from kv extra_var on the CLI
13 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
14 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
15 -t hosts_from_kv_string -v "$@" | tee test_hosts_field.out
16 grep 'Running on 42' test_hosts_field.out 2>&1
17 test "$(grep -c 'ok=1' test_hosts_field.out)" = 1
18
19 # hosts is taken from an all digit json extra_vars string on the CLI
20 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
21 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
22 -t hosts_from_cli_json_string -v "$@" | tee test_hosts_field.out
23 grep 'Running on 42' test_hosts_field.out 2>&1
24 test "$(grep -c 'ok=1' test_hosts_field.out)" = 1
25
26 # hosts is taken from a json list in extra_vars on the CLI
27 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
28 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
29 -t hosts_from_cli_json_list -v "$@" | tee test_hosts_field.out
30 grep 'Running on 42' test_hosts_field.out 2>&1
31 grep 'Running on localhost' test_hosts_field.out 2>&1
32 test "$(grep -c 'ok=1' test_hosts_field.out)" = 2
33
34 # hosts is taken from a json string in an extra_vars file
35 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
36 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
37 -t hosts_from_json_file_string -v "$@" | tee test_hosts_field.out
38 grep 'Running on 42' test_hosts_field.out 2>&1
39 test "$(grep -c 'ok=1' test_hosts_field.out)" = 1
40
41 # hosts is taken from a json list in an extra_vars file
42 ansible-playbook test_hosts_field.yml -i inventory.hosts_field -e 'target_kv=42' \
43 -e '{ "target_json_cli": "42", "target_json_cli_list": ["42", "localhost"] }' -e "@test_hosts_field.json" \
44 -t hosts_from_json_file_list -v "$@" | tee test_hosts_field.out
45 grep 'Running on 42' test_hosts_field.out 2>&1
46 grep 'Running on localhost' test_hosts_field.out 2>&1
47 test "$(grep -c 'ok=1' test_hosts_field.out)" = 2
48
49 rm test_hosts_field.out