tests: split inventory up slightly.

This makes it easier to run connection delegation tests against either
the local machine or a container.
pull/350/head
David Wilson 6 years ago
parent 1473f49505
commit b964e647d2

@ -40,14 +40,16 @@ pip install ansible=="${ANSIBLE_VERSION}"
cd ${TRAVIS_BUILD_DIR}/tests/ansible cd ${TRAVIS_BUILD_DIR}/tests/ansible
chmod go= ${TRAVIS_BUILD_DIR}/tests/data/docker/mitogen__has_sudo_pubkey.key chmod go= ${TRAVIS_BUILD_DIR}/tests/data/docker/mitogen__has_sudo_pubkey.key
echo '[test-targets]' > ${TMPDIR}/hosts mkdir ${TMPDIR}/hosts
ln -s ${TRAVIS_BUILD_DIR}/tests/ansible/common-hosts ${TMPDIR}/hosts/common-hosts
echo '[test-targets]' > ${TMPDIR}/hosts/target
echo \ echo \
target \ target \
ansible_host=$DOCKER_HOSTNAME \ ansible_host=$DOCKER_HOSTNAME \
ansible_port=2201 \ ansible_port=2201 \
ansible_user=mitogen__has_sudo_nopw \ ansible_user=mitogen__has_sudo_nopw \
ansible_password=has_sudo_nopw_password \ ansible_password=has_sudo_nopw_password \
>> ${TMPDIR}/hosts >> ${TMPDIR}/hosts/target
# Build the binaries. # Build the binaries.
make -C ${TRAVIS_BUILD_DIR}/tests/ansible make -C ${TRAVIS_BUILD_DIR}/tests/ansible

@ -25,3 +25,18 @@ environment before the Mitogen connection process forks.
``` ```
ANSIBLE_STRATEGY=mitogen_linear ./run_ansible_playbook.sh all.yml ANSIBLE_STRATEGY=mitogen_linear ./run_ansible_playbook.sh all.yml
``` ```
## ``hosts/`` and ``common-hosts``
To support running the tests against a dev machine that has the requisite user
accounts, the the default inventory is a directory containing a 'localhost'
file that defines 'localhost' to be named 'target' in Ansible inventory, and a
symlink to 'common-hosts', which defines additional targets that all derive
from 'target'.
This allows ``ansible_tests.sh`` to reuse the common-hosts definitions while
replacing localhost as the test target by creating a new directory that
similarly symlinks in common-hosts.
There may be a better solution for this, but it works fine for now.

@ -1,7 +1,3 @@
[test-targets]
localhost
[connection-delegation-test] [connection-delegation-test]
cd-bastion cd-bastion
cd-rack11 mitogen_via=ssh-user@cd-bastion cd-rack11 mitogen_via=ssh-user@cd-bastion
@ -14,3 +10,6 @@ cdc-bastion mitogen_via=cdc-rack11a-docker
cdc-rack11 mitogen_via=ssh-user@cdc-bastion cdc-rack11 mitogen_via=ssh-user@cdc-bastion
cdc-rack11a mitogen_via=root@cdc-rack11 cdc-rack11a mitogen_via=root@cdc-rack11
cdc-rack11a-docker mitogen_via=docker-admin@cdc-rack11a ansible_connection=docker cdc-rack11a-docker mitogen_via=docker-admin@cdc-rack11a ansible_connection=docker
[conn-delegation]
cd-user1 ansible_user=mitogen__user1 ansible_connection=mitogen_sudo mitogen_via=target

@ -0,0 +1,2 @@
[test-targets]
target ansible_hostname=localhost
Loading…
Cancel
Save