ansible/test/integration/targets/become_unprivileged/runme.sh
Rick Elrod 69472a5f8d
Refactor _fixup_perms2 to remove way-nested logic (#70701)
Change:
- Refactoring to make it harder to get wrong and easier to read.
- Generalize become_unprivileged tests and fix some that never worked
  but also never failed.

Test Plan:
- CI, new units/integration tests

Signed-off-by: Rick Elrod <rick@elrod.me>
2020-07-20 18:46:47 -05:00

35 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -eux
begin_sandwich() {
ansible-playbook setup_unpriv_users.yml -i inventory -v "$@"
}
end_sandwich() {
unset ANSIBLE_KEEP_REMOTE_FILES
unset ANSIBLE_COMMON_REMOTE_GROUP
unset ANSIBLE_BECOME_PASS
# Do a few cleanup tasks (nuke users, groups, and homedirs, undo config changes)
ansible-playbook cleanup_unpriv_users.yml -i inventory -v "$@"
# We do these last since they do things like remove groups and will error
# if there are still users in them.
for pb in */cleanup.yml; do
ansible-playbook "$pb" -i inventory -v "$@"
done
}
trap "end_sandwich \"\$@\"" EXIT
# Common group tests
begin_sandwich "$@"
ansible-playbook common_remote_group/setup.yml -i inventory -v "$@"
export ANSIBLE_KEEP_REMOTE_FILES=True
export ANSIBLE_COMMON_REMOTE_GROUP=commongroup
export ANSIBLE_BECOME_PASS='iWishIWereCoolEnoughForRoot!'
ANSIBLE_ACTION_PLUGINS="$(pwd)/action_plugins"
export ANSIBLE_ACTION_PLUGINS
ansible-playbook common_remote_group/test.yml -i inventory -v "$@"
end_sandwich "$@"