Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log ignored exception details to debug log #3900

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Conversation

bluecmd
Copy link
Contributor

@bluecmd bluecmd commented Nov 16, 2023

This allows the user to see the exception stack trace by running in verbose mode.

Example:

DEBUG    Running rule yaml
DEBUG    Running rule args
WARNING  Ignored exception from ArgsRule.<bound method AnsibleLintRule.matchtasks of args: Validating module arguments.> while processing roles/alertmanager/tasks/main.yml (tasks): No module named 'distutils'
DEBUG    Ignored exception details
Traceback (most recent call last):
  File "/home/bluecmd/work/sonix-ansible/ansible/lib64/python3.12/site-packages/ansiblelint/_internal/rules.py", line 93, in getmatches
    matches.extend(method(file))
                   ^^^^^^^^^^^^
  File "/home/bluecmd/work/sonix-ansible/ansible/lib64/python3.12/site-packages/ansiblelint/rules/__init__.py", line 177, in matchtasks
    result = self.matchtask(task, file=file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bluecmd/work/sonix-ansible/ansible/lib64/python3.12/site-packages/ansiblelint/rules/args.py", line 159, in matchtask
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/bluecmd/.ansible/collections/ansible_collections/ansible/posix/plugins/modules/firewalld.py", line 216, in <module>
    from ansible_collections.ansible.posix.plugins.module_utils.firewalld import FirewallTransaction, fw_offline
  File "/home/bluecmd/work/sonix-ansible/ansible/lib64/python3.12/site-packages/ansible/utils/collection_loader/_collection_finder.py", line 594, in exec_module
    exec(code_obj, module.__dict__)
  File "/home/bluecmd/.ansible/collections/ansible_collections/ansible/posix/plugins/module_utils/firewalld.py", line 11, in <module>
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
DEBUG    Running rule avoid-implicit
DEBUG    Running rule command-instead-of-module

This allows the user to see the exception stack trace by running in verbose mode.

Signed-off-by: Christian Svensson <blue@cmd.nu>
@bluecmd bluecmd requested a review from a team as a code owner November 16, 2023 07:53
@bluecmd bluecmd requested review from a team, ssbarnea and cristianonicolai and removed request for a team November 16, 2023 07:53
@ssbarnea ssbarnea added the bug label Nov 27, 2023
@ssbarnea ssbarnea merged commit fa9d1c7 into ansible:main Nov 27, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants