@ -7,14 +7,31 @@ export ANSIBLE_GATHERING=explicit
export ANSIBLE_GATHER_SUBSET = minimal
export ANSIBLE_GATHER_SUBSET = minimal
export ANSIBLE_HOST_PATTERN_MISMATCH = error
export ANSIBLE_HOST_PATTERN_MISMATCH = error
# FUTURE: just use INVENTORY_PATH as-is once ansible-test sets the right dir
# FUTURE: just use INVENTORY_PATH as-is once ansible-test sets the right dir
ipath = ../../$( basename " ${ INVENTORY_PATH :- ../../inventory } " )
ipath = ../../$( basename " ${ INVENTORY_PATH :- ../../inventory } " )
export INVENTORY_PATH = " $ipath "
export INVENTORY_PATH = " $ipath "
# test callback
echo "--- validating callbacks"
ANSIBLE_CALLBACK_WHITELIST = testns.testcoll.usercallback ansible localhost -m ping | grep "usercallback says ok"
# validate FQ callbacks in ansible-playbook
ANSIBLE_CALLBACK_WHITELIST = testns.testcoll.usercallback ansible-playbook noop.yml | grep "usercallback says ok"
# use adhoc for the rest of these tests, must force it to load other callbacks
export ANSIBLE_LOAD_CALLBACK_PLUGINS = 1
# validate redirected callback
ANSIBLE_CALLBACK_WHITELIST = formerly_core_callback ansible localhost -m debug 2>& 1 | grep -- "usercallback says ok"
# validate missing redirected callback
ANSIBLE_CALLBACK_WHITELIST = formerly_core_missing_callback ansible localhost -m debug 2>& 1 | grep -- "Skipping 'formerly_core_missing_callback'"
# validate redirected + removed callback (fatal)
ANSIBLE_CALLBACK_WHITELIST = formerly_core_removed_callback ansible localhost -m debug 2>& 1 | grep -- "testns.testcoll.removedcallback has been removed"
# validate warning on logical duplicate (FQ + unqualified that are the same)
ANSIBLE_CALLBACK_WHITELIST = testns.testcoll.usercallback,formerly_core_callback ansible localhost -m debug 2>& 1 | grep -- "Skipping callback 'formerly_core_callback'"
# ensure non existing callback does not crash ansible
ANSIBLE_CALLBACK_WHITELIST = charlie.gomez.notme ansible localhost -m debug 2>& 1 | grep -- "Skipping 'charlie.gomez.notme'"
unset ANSIBLE_LOAD_CALLBACK_PLUGINS
# adhoc normally shouldn't load non-default plugins- let's be sure
output = $( ANSIBLE_CALLBACK_WHITELIST = testns.testcoll.usercallback ansible localhost -m debug)
if [ [ " ${ output } " = ~ "usercallback says ok" ] ] ; then echo fail; exit 1; fi
echo "--- validating docs"
# test documentation
# test documentation
ansible-doc testns.testcoll.testmodule -vvv | grep -- "- normal_doc_frag"
ansible-doc testns.testcoll.testmodule -vvv | grep -- "- normal_doc_frag"
# same with symlink
# same with symlink
@ -23,14 +40,16 @@ ansible-doc testns.testcoll2.testmodule2 -vvv | grep "Test module"
# now test we can list with symlink
# now test we can list with symlink
ansible-doc -l -vvv| grep "testns.testcoll2.testmodule2"
ansible-doc -l -vvv| grep "testns.testcoll2.testmodule2"
# test adhoc default collection resolution (use unqualified collection module with playbook dir under its collection)
echo "testing adhoc default collection support with explicit playbook dir"
ANSIBLE_PLAYBOOK_DIR = ./collection_root_user/ansible_collections/testns/testcoll ansible localhost -m testmodule
echo "testing bad doc_fragments (expected ERROR message follows)"
echo "testing bad doc_fragments (expected ERROR message follows)"
# test documentation failure
# test documentation failure
ansible-doc testns.testcoll.testmodule_bad_docfrags -vvv 2>& 1 | grep -- "unknown doc_fragment"
ansible-doc testns.testcoll.testmodule_bad_docfrags -vvv 2>& 1 | grep -- "unknown doc_fragment"
echo "--- validating default collection"
# test adhoc default collection resolution (use unqualified collection module with playbook dir under its collection)
echo "testing adhoc default collection support with explicit playbook dir"
ANSIBLE_PLAYBOOK_DIR = ./collection_root_user/ansible_collections/testns/testcoll ansible localhost -m testmodule
# we need multiple plays, and conditional import_playbook is noisy and causes problems, so choose here which one to use...
# 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
if [ [ ${ INVENTORY_PATH } = = *.winrm ] ] ; then
export TEST_PLAYBOOK = windows.yml
export TEST_PLAYBOOK = windows.yml
@ -41,6 +60,7 @@ else
ansible-playbook -i " ${ INVENTORY_PATH } " collection_root_user/ansible_collections/testns/testcoll/playbooks/default_collection_playbook.yml " $@ "
ansible-playbook -i " ${ INVENTORY_PATH } " collection_root_user/ansible_collections/testns/testcoll/playbooks/default_collection_playbook.yml " $@ "
fi
fi
echo "--- validating collections support in playbooks/roles"
# run test playbooks
# run test playbooks
ansible-playbook -i " ${ INVENTORY_PATH } " -v " ${ TEST_PLAYBOOK } " " $@ "
ansible-playbook -i " ${ INVENTORY_PATH } " -v " ${ TEST_PLAYBOOK } " " $@ "
@ -48,6 +68,7 @@ if [[ ${INVENTORY_PATH} != *.winrm ]]; then
ansible-playbook -i " ${ INVENTORY_PATH } " -v invocation_tests.yml " $@ "
ansible-playbook -i " ${ INVENTORY_PATH } " -v invocation_tests.yml " $@ "
fi
fi
echo "--- validating inventory"
# test collection inventories
# test collection inventories
ansible-playbook inventory_test.yml -i a.statichost.yml -i redirected.statichost.yml " $@ "
ansible-playbook inventory_test.yml -i a.statichost.yml -i redirected.statichost.yml " $@ "
@ -85,5 +106,3 @@ fi
./vars_plugin_tests.sh
./vars_plugin_tests.sh
# ensure non existing callback does not crash ansible
ANSIBLE_CALLBACK_WHITELIST = charlie.gomez.notme ansible -m ping localhost