You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe I have identified an issue in the get_token function of the modules that will result in a KeyError instead of the desired Ansible module failure if the Graylog endpoint does not exist or is down.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'body'
fatal: [test-molecule-graylog]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 10.64.34.237 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/molecule/.ansible/tmp/ansible-tmp-1581105797.887236-245989639182613/AnsiballZ_graylog_input.py\", line 102, in <module>\r\n _ansiballz_main()\r\n File \"/home/molecule/.ansible/tmp/ansible-tmp-1581105797.887236-245989639182613/AnsiballZ_graylog_input.py\", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/molecule/.ansible/tmp/ansible-tmp-1581105797.887236-245989639182613/AnsiballZ_graylog_input.py\", line 40, in invoke_module\r\n runpy.run_module(mod_name='ansible.modules.graylog_input', init_globals=None, run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n fname, loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n mod_name, mod_fname, mod_loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n exec code in run_globals\r\n File \"/tmp/ansible_graylog_input_payload_ASMJXC/ansible_graylog_input_payload.zip/ansible/modules/graylog_input.py\", line 199, in <module>\r\n File \"/tmp/ansible_graylog_input_payload_ASMJXC/ansible_graylog_input_payload.zip/ansible/modules/graylog_input.py\", line 173, in main\r\n File \"/tmp/ansible_graylog_input_payload_ASMJXC/ansible_graylog_input_payload.zip/ansible/modules/graylog_input.py\", line 132, in get_token\r\nKeyError: 'body'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
This is caused by this section of error handling here which assumes that it always receives an application error (and not some network level issue):
I believe I have identified an issue in the get_token function of the modules that will result in a KeyError instead of the desired Ansible module failure if the Graylog endpoint does not exist or is down.
Error:
This is caused by this section of error handling here which assumes that it always receives an application error (and not some network level issue):
https://github.com/ReconInfoSec/ansible-graylog-modules/blob/master/library/graylog_collector_configurations.py#L259
This could be fixed by adding something like this:
Which would be much clearer.
I'd be happy to submit a PR for this if wanted.
The text was updated successfully, but these errors were encountered: