From 4d2af3f2cb79b9b71c17ae16ce139e76c5fd614c Mon Sep 17 00:00:00 2001 From: Abhinav Y Date: Tue, 21 Feb 2017 14:23:19 +0530 Subject: [PATCH] fix on hanging docker exec with tty # (exit \$?) is a hack to return correct exit codes when docker exec is run with tty (-t) https://github.com/docker/compose/issues/3379 --- ansible-role-ipaserver/docker-tests.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ansible-role-ipaserver/docker-tests.sh b/ansible-role-ipaserver/docker-tests.sh index 2fd0506..30412d4 100644 --- a/ansible-role-ipaserver/docker-tests.sh +++ b/ansible-role-ipaserver/docker-tests.sh @@ -135,16 +135,16 @@ get_container_ip() { exec_container() { id="$(get_container_id)" set -x - docker exec \ + docker exec -it \ "${id}" \ - bash -c "${@}" + bash -ic "${@}" set +x } run_syntax_check() { log "Running syntax check on playbook" log "Working on ansible version : ${ansible_version}" - exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} --syntax-check && deactivate && exit" + exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} --syntax-check && deactivate ; (exit \$?)" } run_playbook() { @@ -153,7 +153,7 @@ run_playbook() { local output output="$(mktemp)" - exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} && deactivate && exit" 2>&1 | tee "${output}" + exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} && deactivate ; (exit \$?)" 2>&1 | tee "${output}" if grep -q 'changed=.*failed=0' "${output}"; then result='pass' @@ -174,7 +174,7 @@ run_idempotence_test() { local output output="$(mktemp)" - exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} && deactivate && exit" 2>&1 | tee "${output}" + exec_container "source ~/.bashrc && workon ansible_${ansible_version} && ansible-playbook ${test_playbook} && deactivate ; (exit \$?)" 2>&1 | tee "${output}" if grep -q 'changed=0.*failed=0' "${output}"; then result='pass'