Debian Codegraph @

test/integration/targets/become_unprivileged/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 export ANSIBLE_KEEP_REMOTE_FILES=True
6 ANSIBLE_ACTION_PLUGINS="$(pwd)/action_plugins"
7 export ANSIBLE_ACTION_PLUGINS
8 export ANSIBLE_BECOME_PASS='iWishIWereCoolEnoughForRoot!'
9
10 begin_sandwich() {
11 ansible-playbook setup_unpriv_users.yml -i inventory -v "$@"
12 }
13
14 end_sandwich() {
15 unset ANSIBLE_KEEP_REMOTE_FILES
16 unset ANSIBLE_COMMON_REMOTE_GROUP
17 unset ANSIBLE_BECOME_PASS
18
19 # Do a few cleanup tasks (nuke users, groups, and homedirs, undo config changes)
20 ansible-playbook cleanup_unpriv_users.yml -i inventory -v "$@"
21
22 # We do these last since they do things like remove groups and will error
23 # if there are still users in them.
24 for pb in */cleanup.yml; do
25 ansible-playbook "$pb" -i inventory -v "$@"
26 done
27 }
28
29 trap "end_sandwich \"\$@\"" EXIT
30
31 # Common group tests
32 # Skip on macOS, chmod fallback will take over.
33 # 1) chmod is stupidly hard to disable, so hitting this test case on macOS would
34 # be a suuuuuuper edge case scenario
35 # 2) even if we can trick it so chmod doesn't exist, then other things break.
36 # Ansible wants a `chmod` around, even if it's not the final thing that gets
37 # us enough permission to run the task.
38 if [[ "$OSTYPE" != darwin* ]]; then
39 begin_sandwich "$@"
40 ansible-playbook common_remote_group/setup.yml -i inventory -v "$@"
41 export ANSIBLE_COMMON_REMOTE_GROUP=commongroup
42 ansible-playbook common_remote_group/test.yml -i inventory -v "$@"
43 end_sandwich "$@"
44 fi
45
46 if [[ "$OSTYPE" == darwin* ]]; then
47 begin_sandwich "$@"
48 # In the default case this should happen on macOS, so no need for a setup
49 # It should just work.
50 ansible-playbook chmod_acl_macos/test.yml -i inventory -v "$@"
51 end_sandwich "$@"
52 fi