Skip to content

filter(ansible): add ansible-playbook filter #44

@mpecan

Description

@mpecan

Goal

Add a filter for ansible-playbook — one of the most widely used configuration management and automation tools, with notoriously verbose CI output.

Background

Every Ansible task emits at minimum two lines per host: the task name header and the result. A playbook with 100 tasks across 50 hosts generates 5,000+ lines, the vast majority being ok: [hostname] (no change occurred). In CI, these overwhelm the actual signal.

The meaningful lines are:

  • changed: [hostname] — something was modified (worth knowing)
  • failed: [hostname] — something broke (critical)
  • fatal: [hostname] — unrecoverable failure (critical)
  • PLAY RECAP — the final summary

ok and skipping lines represent zero new information in post-run review.

Filters to Add

ansible/playbook.tomlansible-playbook

  • Skip:
    • ok: [hostname] result lines
    • skipping: [hostname] result lines
    • TASK [role : task name] ****... header lines for tasks that resulted in ok or skipping
  • Keep:
    • changed: [hostname] result lines (with their preceding task header)
    • failed: [hostname] result lines (with preceding task header)
    • fatal: [hostname] result lines
    • PLAY RECAP section and all lines within it
    • PLAY [play name] headers
    • Lines containing msg: from failed tasks (the error message)

Consider section parsing: track each TASK [...] header, then decide to keep or discard based on whether the result line is ok/skipping vs changed/failed/fatal.

ansible/lint.tomlansible-lint

  • Skip: [WARNING] lines from rules at warning severity when error level violations exist
  • Keep: All violation lines with rule ID and file:line reference, summary

Fixture Files Needed

  • tests/fixtures/ansible/playbook-allok.txt — large playbook run with all tasks ok
  • tests/fixtures/ansible/playbook-changes.txt — playbook with mix of ok, changed, skipping
  • tests/fixtures/ansible/playbook-failure.txt — playbook with a task failure
  • tests/fixtures/ansible/lint-violations.txt — ansible-lint output with errors and warnings

Acceptance Criteria

  • ok: and skipping: task result lines removed from output
  • changed: lines and their task headers preserved
  • failed: / fatal: lines and their task headers and error messages preserved
  • PLAY RECAP section always fully preserved
  • Integration tests pass for all fixture files

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions