Debian Codegraph @

test/integration/targets/adhoc/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # run type tests
6 ansible -a 'sleep 5' --task-timeout 1 localhost |grep 'Timed out after'
7
8 # -a parsing with json
9 ansible --task-timeout 5 localhost -m command -a '{"cmd": "whoami"}' | grep 'rc=0'
10
11 # ensure that legacy deserializer behaves as expected on JSON CLI args (https://github.com/ansible/ansible/issues/82600)
12 # also ensure that various templated args function (non-exhaustive)
13 _ANSIBLE_TEMPLAR_UNTRUSTED_TEMPLATE_BEHAVIOR=warning ansible '{{"localhost"}}' -m '{{"debug"}}' -a var=fromcli -e '{"fromcli":{"no_trust":{"__ansible_unsafe":"{{\"hello\"}}"},"trust":"{{ 1 }}"}}' > "${OUTPUT_DIR}/output.txt" 2>&1
14 grep '"no_trust": "{{."hello."}}"' "${OUTPUT_DIR}/output.txt" # ensure that the template was not rendered
15 grep '"trust": 1' "${OUTPUT_DIR}/output.txt" # ensure that the trusted template was rendered
16 grep "Encountered untrusted template" "${OUTPUT_DIR}/output.txt" # look for the untrusted template warning text
17
18 # test ansible --flush-cache
19 export ANSIBLE_CACHE_PLUGIN=jsonfile
20 export ANSIBLE_CACHE_PLUGIN_CONNECTION=./
21 # verify facts are not yet present
22 ansible localhost -m assert -a '{"that": "ansible_facts.distribution is not defined"}'
23 # collect and cache facts
24 ansible localhost -m setup > /dev/null
25 # verify facts were cached
26 ansible localhost -m assert -a '{"that": "ansible_facts.distribution is defined"}'
27 # test flushing the fact cache
28 ansible --flush-cache localhost -m debug -a "msg={{ ansible_facts }}" | grep '"msg": {}'
29 # test meta end_play
30 ansible localhost -m include_role -a name=end_play