2019-03-28 18:41:39 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
export ANSIBLE_COLLECTIONS_PATHS=$PWD/collection_root_user:$PWD/collection_root_sys
|
|
|
|
export ANSIBLE_GATHERING=explicit
|
|
|
|
export ANSIBLE_GATHER_SUBSET=minimal
|
2019-04-11 07:59:53 +02:00
|
|
|
export ANSIBLE_HOST_PATTERN_MISMATCH=error
|
|
|
|
|
2019-08-29 01:31:40 +02:00
|
|
|
|
|
|
|
# FUTURE: just use INVENTORY_PATH as-is once ansible-test sets the right dir
|
2019-04-11 07:59:53 +02:00
|
|
|
ipath=../../$(basename "${INVENTORY_PATH}")
|
|
|
|
export INVENTORY_PATH="$ipath"
|
2019-03-28 18:41:39 +01:00
|
|
|
|
|
|
|
# test callback
|
|
|
|
ANSIBLE_CALLBACK_WHITELIST=testns.testcoll.usercallback ansible localhost -m ping | grep "usercallback says ok"
|
|
|
|
|
2019-05-03 03:15:58 +02:00
|
|
|
# test documentation
|
|
|
|
ansible-doc testns.testcoll.testmodule -vvv | grep -- "- normal_doc_frag"
|
|
|
|
|
2019-08-21 11:45:04 +02:00
|
|
|
echo "testing bad doc_fragments (expected ERROR message follows)"
|
|
|
|
# test documentation failure
|
|
|
|
ansible-doc testns.testcoll.testmodule_bad_docfrags -vvv 2>&1 | grep -- "unknown doc_fragment"
|
|
|
|
|
2019-04-11 07:59:53 +02:00
|
|
|
# we need multiple plays, and conditional import_playbook is noisy and causes problems, so choose here which one to use...
|
|
|
|
if [[ ${INVENTORY_PATH} == *.winrm ]]; then
|
|
|
|
export TEST_PLAYBOOK=windows.yml
|
|
|
|
else
|
|
|
|
export TEST_PLAYBOOK=posix.yml
|
2019-08-29 01:31:40 +02:00
|
|
|
|
|
|
|
echo "testing default collection support"
|
|
|
|
ansible-playbook -i "${INVENTORY_PATH}" collection_root_user/ansible_collections/testns/testcoll/playbooks/default_collection_playbook.yml
|
2019-04-11 07:59:53 +02:00
|
|
|
fi
|
|
|
|
|
2019-03-28 18:41:39 +01:00
|
|
|
# run test playbook
|
2019-08-28 01:02:27 +02:00
|
|
|
ansible-playbook -i "${INVENTORY_PATH}" -i ./a.statichost.yml -v "${TEST_PLAYBOOK}" "$@"
|
2019-05-22 17:06:54 +02:00
|
|
|
|
|
|
|
# test adjacent with --playbook-dir
|
|
|
|
export ANSIBLE_COLLECTIONS_PATHS=''
|
|
|
|
ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=1 ansible-inventory -i a.statichost.yml --list --export --playbook-dir=. -v "$@"
|