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

Fix to avoid spamming syslog with invoked messages #4353

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tanwigeetika1618
Copy link
Contributor

@tanwigeetika1618 tanwigeetika1618 commented Oct 1, 2024

Fix issue #4317

Description

This PR resolves the issue where ansible-basic.py was unnecessarily logging invoked messages to the local syslog, leading to excessive and irrelevant logging during playbook execution.

Changes

  • Modified CustomAnsibleModule in args.py to modify the initialization process.
    -Preventing the unnecessary execution of AnsibleModule.
  • This stops the spamming of syslog with messages such as "ansible-basic.py Invoked with...".

Impact

  • Significantly reduces irrelevant syslog entries.
  • Verified by running ansible-lint and checking logs with journalctl | grep ansible.

@tanwigeetika1618 tanwigeetika1618 requested a review from a team as a code owner October 1, 2024 12:41
@tanwigeetika1618 tanwigeetika1618 requested review from audgirka and alisonlhart and removed request for a team October 1, 2024 12:41
@tanwigeetika1618 tanwigeetika1618 self-assigned this Oct 1, 2024
Comment on lines +76 to 79
def __init__(self, *args: str, **kwargs: Any) -> None:
"""Initialize AnsibleModule mock."""
kwargs["no_log"] = True
super().__init__(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the idea of introducing Any anywhere if we can help it. We could make the type str | bool instead, assuming that previously we are only ever calling it with strings.

Suggested change
def __init__(self, *args: str, **kwargs: Any) -> None:
"""Initialize AnsibleModule mock."""
kwargs["no_log"] = True
super().__init__(*args, **kwargs)
def __init__(self, *args: str, **kwargs: str | bool) -> None:
"""Initialize AnsibleModule mock."""
kwargs["no_log"] = True
super().__init__(*args, **kwargs)

We could instead keep the hint but instead kwargs.pop("no_log") and then pass no_log=True directly to super().__init__(), but I'm not convinced str actually is the correct type here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants