Initial commit

This commit is contained in:
Jon Ervine
2021-03-03 11:36:53 +08:00
parent a5dc995324
commit 4cdbe9a6d5
137 changed files with 12374 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# In OpenShift, containers are run as a random high number uid
# that doesn't exist in /etc/passwd, but Ansible module utils
# require a named user. So if we're in OpenShift, we need to make
# one before Ansible runs.
if [[ (`id -u` -ge 500 || -z "${CURRENT_UID}") ]]; then
# Only needed for RHEL 8. Try deleting this conditional (not the code)
# sometime in the future. Seems to be fixed on Fedora 32
# If we are running in rootless podman, this file cannot be overwritten
ROOTLESS_MODE=$(cat /proc/self/uid_map | head -n1 | awk '{ print $2; }')
if [[ "$ROOTLESS_MODE" -eq "0" ]]; then
cat << EOF > /etc/passwd
root:x:0:0:root:/root:/bin/bash
runner:x:`id -u`:`id -g`:,,,:/home/runner:/bin/bash
EOF
fi
cat <<EOF > /etc/group
root:x:0:runner
runner:x:`id -g`:
EOF
fi
if [[ -n "${LAUNCHED_BY_RUNNER}" ]]; then
RUNNER_CALLBACKS=$(python3 -c "import ansible_runner.callbacks; print(ansible_runner.callbacks.__file__)")
# TODO: respect user callback settings via
# env ANSIBLE_CALLBACK_PLUGINS or ansible.cfg
export ANSIBLE_CALLBACK_PLUGINS="$(dirname $RUNNER_CALLBACKS)"
fi
if [[ -d ${AWX_ISOLATED_DATA_DIR} ]]; then
if output=$(ansible-galaxy collection list --format json 2> /dev/null); then
echo $output > ${AWX_ISOLATED_DATA_DIR}/collections.json
fi
fi
exec /usr/local/bin/dumb-init -- "${@}"
+40
View File
@@ -0,0 +1,40 @@
import os
import imp
"""
This script allows creating a directory structure that corresponds to the
parameterized inputs present in the file test/integration/test_display_callback.py
Run this from the root of the ansible-runner directory
It will write these files to a folder named "callback-testing-playbooks"
"""
callback_tests = imp.load_source('test.integration.test_display_callback', 'test/integration/test_display_callback.py')
BASE_DIR = 'callback-testing-playbooks'
names = [test_name for test_name in dir(callback_tests) if test_name.startswith('test_')]
for name in names:
print('')
print('Processing test {}'.format(name))
bare_name = name[len('test_callback_plugin_'):]
if not os.path.exists('{}/{}'.format(BASE_DIR, bare_name)):
os.makedirs('{}/{}'.format(BASE_DIR, bare_name))
the_test = getattr(callback_tests, name)
for test_marker in the_test.pytestmark:
if test_marker.name == 'parametrize':
inputs = test_marker.args[1]
break
else:
raise Exception('Test {} not parameterized in expected way.'.format(the_test))
for input in inputs:
for k, v in input.items():
filename = '{}/{}/{}'.format(BASE_DIR, bare_name, k)
print(' Writing file {}'.format(filename))
if not os.path.exists(filename):
with open(filename, 'w') as f:
f.write(v)