Skip to content

Improve Ansible error extraction code #513

@comps

Description

@comps

The current ansible-playbook output parsing code,

m = re.fullmatch(r'([\w]+): \[.+\](: [^ ]+)?( =>)? (.+)', line, flags=re.DOTALL)
, doesn't seem to catch complex errors.

For example this:

TASK [Ensure Active Authselect Profile Includes PAM Modules - Informative message based on the authselect integrity check result] ***
fatal: [192.168.123.157]: FAILED! => {
    "assertion": "ansible_check_mode or result_authselect_check_cmd.rc == 0",
    "changed": false,
    "evaluated_to": false,
    "msg": [
        "authselect integrity check failed. Remediation aborted!",
        "This remediation could not be applied because an authselect profile was not selected or the selected profile is not intact.",
        "It is not recommended to manually edit the PAM files when authselect tool is available.",
        "In cases where the default authselect profile does not cover a specific demand, a custom authselect profile is recommended."
    ]
}

causes the { to become the full error message,

2026-01-09 11:15:15 test.py:49: lib.results.report_plain:184: ERROR playbook: Ensure Active Authselect Profile Includes PAM Modules - Informative message based on the authselect integrity check result ({)

(see the last 3 characters)

I don't necessarily think we should parse every possible Ansible error output, but seeing just { makes it appear like a Contest bug, so maybe the note should be empty, or mention something like "complex error found, see ansible-playbook.log".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions