Improve rendering of ansible errors
When using play_on or run_command, if there is an error, we get the following (unhelpful) output:
Failed hosts: [_AnsibleExecutionRecord(host='grimoire-1.nancy.grid5000.fr', status='FAILED', task='command', payload={'msg': 'Unsupported parameters for (ansible.legacy.command) module: shell. Supported parameters include: strip_empty_ends, _raw_params, warn, argv, creates, removes, executable, stdin_add_newline, _uses_shell, stdin, chdir.', 'invocation': {'module_args': {'shell': True, '_raw_params': "echo -e 'label: gpt\n,,raid' | sfdisk /dev/disk1", '_uses_shell': False, 'warn': False, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, '_ansible_no_log': None, 'changed': False}), _AnsibleExecutionRecord(host='grimoire-5.nancy.grid5000.fr', status='FAILED', task='command', payload={'msg': 'Unsupported parameters for (ansible.legacy.command) module: shell. Supported parameters include: _raw_params, creates, argv, _uses_shell, strip_empty_ends, stdin, removes, warn, chdir, executable, stdin_add_newline.', 'invocation': {'module_args': {'shell': True, '_raw_params': "echo -e 'label: gpt\n,,raid' | sfdisk /dev/disk1", '_uses_shell': False, 'warn': False, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, '_ansible_no_log': None, 'changed': False})]
This is very common while developing an experiment with Enoslib, and unfortunately this output is hard to parse to understand the problem.
We could try to improve the output:
- display
msg
, which is often helpful when Ansible is misused (like the above) - display
rc
,stderr
which is useful when the command itself failed on the target machine - we could also display
task
and_raw_params
to give more context - split the error for each machine on its own line