diff --git a/.travis/ansible_tests.sh b/.travis/ansible_tests.sh index e6441343..bc119149 100755 --- a/.travis/ansible_tests.sh +++ b/.travis/ansible_tests.sh @@ -40,14 +40,16 @@ pip install ansible=="${ANSIBLE_VERSION}" cd ${TRAVIS_BUILD_DIR}/tests/ansible 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 \ target \ ansible_host=$DOCKER_HOSTNAME \ ansible_port=2201 \ ansible_user=mitogen__has_sudo_nopw \ ansible_password=has_sudo_nopw_password \ - >> ${TMPDIR}/hosts + >> ${TMPDIR}/hosts/target # Build the binaries. make -C ${TRAVIS_BUILD_DIR}/tests/ansible diff --git a/tests/ansible/README.md b/tests/ansible/README.md index a76c7c1f..8051ef85 100644 --- a/tests/ansible/README.md +++ b/tests/ansible/README.md @@ -25,3 +25,18 @@ environment before the Mitogen connection process forks. ``` 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. diff --git a/tests/ansible/hosts b/tests/ansible/common-hosts similarity index 81% rename from tests/ansible/hosts rename to tests/ansible/common-hosts index 45bfb9ef..0aead1be 100644 --- a/tests/ansible/hosts +++ b/tests/ansible/common-hosts @@ -1,7 +1,3 @@ - -[test-targets] -localhost - [connection-delegation-test] 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-rack11a mitogen_via=root@cdc-rack11 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 diff --git a/tests/ansible/hosts/common-hosts b/tests/ansible/hosts/common-hosts new file mode 120000 index 00000000..f3cc7f59 --- /dev/null +++ b/tests/ansible/hosts/common-hosts @@ -0,0 +1 @@ +../common-hosts \ No newline at end of file diff --git a/tests/ansible/hosts/localhost b/tests/ansible/hosts/localhost new file mode 100644 index 00000000..6e022a01 --- /dev/null +++ b/tests/ansible/hosts/localhost @@ -0,0 +1,2 @@ +[test-targets] +target ansible_hostname=localhost