Debian Codegraph @

test/integration/targets/fetch/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 function cleanup {
6 ansible-playbook -i "${INVENTORY_PATH}" cleanup.yml -e "output_dir=${OUTPUT_DIR}" -b "$@"
7 unset ANSIBLE_CACHE_PLUGIN
8 unset ANSIBLE_CACHE_PLUGIN_CONNECTION
9 }
10
11 trap 'cleanup "$@"' EXIT
12
13 # setup required roles
14 ln -s ../../setup_remote_tmp_dir roles/setup_remote_tmp_dir
15
16 # run old type role tests
17 ansible-playbook -i ../../inventory run_fetch_tests.yml -e "output_dir=${OUTPUT_DIR}" "$@"
18
19 # run same test with become
20 ansible-playbook -i ../../inventory run_fetch_tests.yml -e "output_dir=${OUTPUT_DIR}" -b "$@"
21
22 # run tests to avoid path injection from slurp when fetch uses become
23 ansible-playbook -i ../../inventory injection/avoid_slurp_return.yml -e "output_dir=${OUTPUT_DIR}" "$@"
24
25 ## Test unreadable file with stat. Requires running without become and as a user other than root.
26 #
27 # Change the known_hosts file to avoid changing the test environment
28 export ANSIBLE_CACHE_PLUGIN=jsonfile
29 export ANSIBLE_CACHE_PLUGIN_CONNECTION="${OUTPUT_DIR}/cache"
30 # Create a non-root user account and configure SSH access for that account
31 ansible-playbook -i "${INVENTORY_PATH}" setup_unreadable_test.yml -e "output_dir=${OUTPUT_DIR}" "$@"
32
33 # Run the tests as the unprivileged user without become to test the use of the stat module from the fetch module
34 ansible-playbook -i "${INVENTORY_PATH}" test_unreadable_with_stat.yml -e ansible_user=fetcher -e ansible_become=no -e "output_dir=${OUTPUT_DIR}" "$@"