Recognize module tracebacks on stdout and stderr.
Module tracebacks may be reported on stdout instead of stderr when using some connection plugins. For example, the ssh connection plugin will report tracebacks on stdout due to use of the -tt option. This change results in tracebacks being recognized on both stdout and stderr, instead of the previous behavior of just stderr. ci_complete
This commit is contained in:
parent
11e2ac3abf
commit
f109184753
6 changed files with 39 additions and 0 deletions
2
changelogs/fragments/module-exceptions.yaml
Normal file
2
changelogs/fragments/module-exceptions.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Module tracebacks are now recognized on stdout and stderr, intead of just on stderr.
|
|
@ -992,6 +992,10 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
if res['stderr'].startswith(u'Traceback'):
|
||||
data['exception'] = res['stderr']
|
||||
|
||||
# in some cases a traceback will arrive on stdout instead of stderr, such as when using ssh with -tt
|
||||
if 'exception' not in data and data['module_stdout'].startswith(u'Traceback'):
|
||||
data['exception'] = data['module_stdout']
|
||||
|
||||
# The default
|
||||
data['msg'] = "MODULE FAILURE"
|
||||
|
||||
|
|
2
test/integration/targets/module_tracebacks/aliases
Normal file
2
test/integration/targets/module_tracebacks/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
shippable/posix/group4
|
||||
needs/ssh
|
5
test/integration/targets/module_tracebacks/inventory
Normal file
5
test/integration/targets/module_tracebacks/inventory
Normal file
|
@ -0,0 +1,5 @@
|
|||
testhost_local ansible_connection=local
|
||||
testhost_ssh ansible_connection=ssh ansible_host=localhost
|
||||
|
||||
[all:vars]
|
||||
ansible_python_interpreter="{{ ansible_playbook_python }}"
|
5
test/integration/targets/module_tracebacks/runme.sh
Executable file
5
test/integration/targets/module_tracebacks/runme.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook traceback.yml -i inventory "$@"
|
21
test/integration/targets/module_tracebacks/traceback.yml
Normal file
21
test/integration/targets/module_tracebacks/traceback.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
- hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: intentionally fail module execution
|
||||
ping:
|
||||
data: crash
|
||||
ignore_errors: yes
|
||||
register: ping
|
||||
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: verify exceptions were properly captured
|
||||
assert:
|
||||
that:
|
||||
- hostvars.testhost_local.ping is failed
|
||||
- "'boom' in hostvars.testhost_local.ping.exception"
|
||||
- "'boom' in hostvars.testhost_local.ping.module_stderr"
|
||||
- hostvars.testhost_ssh.ping is failed
|
||||
- "'boom' in hostvars.testhost_ssh.ping.exception"
|
||||
- "'boom' in hostvars.testhost_ssh.ping.module_stdout"
|
Loading…
Add table
Reference in a new issue