be0cdc0ea2
* Remove use of _remote_checksum from fetch module * Add deprecation message displayed during runtime * Increase test coverage for fetch * Add tests covering the use of stat from the fetch module This required creating an unpriveleged user account and connecting as that user remotely since it is not possible to create a file that the root user cannot stat. * Use fact caching to persist remote tmp dir across playbook runs * Add variables to setup_remote_tmp test role to allow caching of the remote temp dir fact and preventing removal of the remote_tmp_dir
34 lines
1.4 KiB
Bash
Executable file
34 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -eux
|
|
|
|
function cleanup {
|
|
ansible-playbook -i hosts.yml cleanup.yml -e "output_dir=${OUTPUT_DIR}" -b "$@"
|
|
unset ANSIBLE_CACHE_PLUGIN
|
|
unset ANSIBLE_CACHE_PLUGIN_CONNECTION
|
|
}
|
|
|
|
trap 'cleanup "$@"' EXIT
|
|
|
|
# setup required roles
|
|
ln -s ../../setup_remote_tmp_dir roles/setup_remote_tmp_dir
|
|
|
|
# run old type role tests
|
|
ansible-playbook -i ../../inventory run_fetch_tests.yml -e "output_dir=${OUTPUT_DIR}" "$@"
|
|
|
|
# run same test with become
|
|
ansible-playbook -i ../../inventory run_fetch_tests.yml -e "output_dir=${OUTPUT_DIR}" -b "$@"
|
|
|
|
# run tests to avoid path injection from slurp when fetch uses become
|
|
ansible-playbook -i ../../inventory injection/avoid_slurp_return.yml -e "output_dir=${OUTPUT_DIR}" "$@"
|
|
|
|
## Test unreadable file with stat. Requires running without become and as a user other than root.
|
|
#
|
|
# Change the known_hosts file to avoid changing the test environment
|
|
export ANSIBLE_CACHE_PLUGIN=jsonfile
|
|
export ANSIBLE_CACHE_PLUGIN_CONNECTION="${OUTPUT_DIR}/cache"
|
|
# Create a non-root user account and configure SSH acccess for that account
|
|
ansible-playbook -i hosts.yml setup_unreadable_test.yml -e "output_dir=${OUTPUT_DIR}" "$@"
|
|
|
|
# Run the tests as the unprivileged user without become to test the use of the stat module from the fetch module
|
|
ansible-playbook --user fetcher -i hosts.yml test_unreadable_with_stat.yml -e "output_dir=${OUTPUT_DIR}" "$@"
|