tests: use non-root SSH user to connect to Docker image in ansible_test.
This commit is contained in:
parent
00aef80fac
commit
b81a47649e
|
@ -6,6 +6,12 @@ TMPDIR="/tmp/ansible-tests-$$"
|
||||||
ANSIBLE_VERSION="${ANSIBLE_VERSION:-2.4.3.0}"
|
ANSIBLE_VERSION="${ANSIBLE_VERSION:-2.4.3.0}"
|
||||||
MITOGEN_TEST_DISTRO="${MITOGEN_TEST_DISTRO:-debian}"
|
MITOGEN_TEST_DISTRO="${MITOGEN_TEST_DISTRO:-debian}"
|
||||||
|
|
||||||
|
export PYTHONPATH="${PYTHONPATH}:${TRAVIS_BUILD_DIR}"
|
||||||
|
|
||||||
|
# SSH passes these through to the container when run interactively, causing
|
||||||
|
# stdout to get messed up with libc warnings.
|
||||||
|
unset LANG LC_ALL
|
||||||
|
|
||||||
function on_exit()
|
function on_exit()
|
||||||
{
|
{
|
||||||
rm -rf "$TMPDIR"
|
rm -rf "$TMPDIR"
|
||||||
|
@ -17,7 +23,14 @@ mkdir "$TMPDIR"
|
||||||
|
|
||||||
|
|
||||||
echo travis_fold:start:docker_setup
|
echo travis_fold:start:docker_setup
|
||||||
docker run --rm --detach --name=target d2mw/mitogen-${MITOGEN_TEST_DISTRO}-test /bin/sleep 86400
|
DOCKER_HOSTNAME="$(python ${TRAVIS_BUILD_DIR}/tests/show_docker_hostname.py)"
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
--detach \
|
||||||
|
--publish 0.0.0.0:2201:22/tcp \
|
||||||
|
--name=target \
|
||||||
|
d2mw/mitogen-${MITOGEN_TEST_DISTRO}-test
|
||||||
echo travis_fold:end:docker_setup
|
echo travis_fold:end:docker_setup
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,9 +38,15 @@ echo travis_fold:start:job_setup
|
||||||
pip install -U ansible=="${ANSIBLE_VERSION}"
|
pip install -U ansible=="${ANSIBLE_VERSION}"
|
||||||
cd ${TRAVIS_BUILD_DIR}/tests/ansible
|
cd ${TRAVIS_BUILD_DIR}/tests/ansible
|
||||||
|
|
||||||
cat >> ${TMPDIR}/hosts <<-EOF
|
echo \
|
||||||
target ansible_connection=docker ansible_python_interpreter=/usr/bin/python2.7
|
target \
|
||||||
EOF
|
ansible_host=$DOCKER_HOSTNAME \
|
||||||
|
ansible_port=2201 \
|
||||||
|
ansible_python_interpreter=/usr/bin/python2.7 \
|
||||||
|
ansible_user=mitogen__has_sudo_pubkey \
|
||||||
|
ansible_become_pass=has_sudo_pubkey_password \
|
||||||
|
ansible_ssh_private_key_file=${TRAVIS_BUILD_DIR}/tests/data/docker/mitogen__has_sudo_pubkey.key \
|
||||||
|
>> ${TMPDIR}/hosts
|
||||||
echo travis_fold:end:job_setup
|
echo travis_fold:end:job_setup
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue