Skip to content

Commit

Permalink
fix on hanging docker exec with tty
Browse files Browse the repository at this point in the history
# (exit \$?) is a hack to return correct exit codes when docker exec is run with tty (-t)
docker/compose#3379
  • Loading branch information
yabhinav committed Feb 21, 2017
1 parent 4001df1 commit 4d2af3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ansible-role-ipaserver/docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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'
Expand All @@ -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'
Expand Down

0 comments on commit 4d2af3f

Please sign in to comment.