2017-08-02 21:57:58 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
|
|
|
|
trap 'rm -rf "${MYTMPDIR}"' EXIT
|
|
|
|
|
2018-04-06 01:57:34 +02:00
|
|
|
# ensure we can incrementally set fact via loopi, injection or not
|
2019-01-15 09:24:03 +01:00
|
|
|
ANSIBLE_INJECT_FACT_VARS=0 ansible-playbook -i inventory incremental.yml
|
|
|
|
ANSIBLE_INJECT_FACT_VARS=1 ansible-playbook -i inventory incremental.yml
|
2017-08-02 21:57:58 +02:00
|
|
|
|
2018-04-06 01:57:34 +02:00
|
|
|
# ensure we dont have spurious warnings do to clean_facts
|
2019-01-15 09:24:03 +01:00
|
|
|
ansible-playbook -i inventory nowarn_clean_facts.yml | grep '[WARNING]: Removed restricted key from module data: ansible_ssh_common_args' && exit 1
|
2017-08-02 21:57:58 +02:00
|
|
|
|
2018-04-06 01:57:34 +02:00
|
|
|
# test cached feature
|
2020-06-11 16:40:25 +02:00
|
|
|
export ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CACHE_PLUGIN_CONNECTION="${MYTMPDIR}" ANSIBLE_CACHE_PLUGIN_PREFIX=prefix_
|
2019-01-15 09:24:03 +01:00
|
|
|
ansible-playbook -i inventory "$@" set_fact_cached_1.yml
|
|
|
|
ansible-playbook -i inventory "$@" set_fact_cached_2.yml
|
2020-06-11 16:40:25 +02:00
|
|
|
|
|
|
|
# check contents of the fact cache directory before flushing it
|
|
|
|
if [[ "$(find "${MYTMPDIR}" -type f)" != $MYTMPDIR/prefix_* ]]; then
|
|
|
|
echo "Unexpected cache file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-15 09:24:03 +01:00
|
|
|
ansible-playbook -i inventory --flush-cache "$@" set_fact_no_cache.yml
|
2018-07-30 22:44:38 +02:00
|
|
|
|
|
|
|
# Test boolean conversions in set_fact
|
2020-09-24 21:52:06 +02:00
|
|
|
ANSIBLE_JINJA2_NATIVE=0 ansible-playbook -v set_fact_bool_conv.yml
|
2018-07-30 22:44:38 +02:00
|
|
|
ANSIBLE_JINJA2_NATIVE=1 ansible-playbook -v set_fact_bool_conv_jinja2_native.yml
|
2020-11-20 19:22:55 +01:00
|
|
|
|
|
|
|
# Test parsing of values when using an empty string as a key
|
|
|
|
ansible-playbook -i inventory set_fact_empty_str_key.yml
|