Debian Codegraph @

test/integration/targets/pause/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 source virtualenv.sh
6
7 pip install pexpect==4.9.0
8
9 # Test pause module when no tty and non-interactive with no seconds parameter.
10 # This is to prevent playbooks from hanging in cron and Tower jobs.
11 /usr/bin/env bash << EOF
12 ansible-playbook test-pause-no-tty.yml 2>&1 | \
13 grep '\[WARNING\]: Not waiting for response to prompt as stdin is not interactive' && {
14 echo 'Successfully skipped pause in no TTY mode' >&2
15 exit 0
16 } || {
17 echo 'Failed to skip pause module' >&2
18 exit 1
19 }
20 EOF
21
22 # Do not issue a warning when run in the background if a timeout is given
23 # https://github.com/ansible/ansible/issues/73042
24 if sleep 0 | ansible localhost -m pause -a 'seconds=1' 2>&1 | grep '\[WARNING\]: Not waiting for response'; then
25 echo "Incorrectly issued warning when run in the background"
26 exit 1
27 else
28 echo "Successfully ran in the background with no warning"
29 fi
30
31 # Test redirecting stdout
32 # https://github.com/ansible/ansible/issues/41717
33 if ansible-playbook pause-3.yml > /dev/null ; then
34 echo "Successfully redirected stdout"
35 else
36 echo "Failure when attempting to redirect stdout"
37 exit 1
38 fi
39
40
41 # Test pause with seconds and minutes specified
42 ansible-playbook test-pause.yml "$@"
43
44 # Interactively test pause
45 python test-pause.py "$@"