A terminal user interface (TUI) for viewing and analyzing Ansible log files, built with Go and Bubbletea.
- Parse Ansible log files to extract tasks
- Display tasks in a scrollable list with their status (ok, changed, skipping, failed)
- Navigate through tasks using keyboard controls
- Expand/collapse tasks to view detailed information without changing panels
- View full raw task text in a separate details panel when a task is expanded
- Details panel height fixed to 1/3 of the screen
- Details panel width fixed to full screen width
- Raw text content in details panel wraps if lines are too long
- Details panel is scrollable with PgUp/PgDn keys
- Color-coded status indicators for quick visual identification
- Filter tasks by description, status, date, host, path, or diff content
- Debug logging of task structure to debug.log file
-
Clone the repository:
git clone <repository-url> cd ansible-logs-view -
Build the application:
make build -
Build the application linked with older glic-2.28. This would require
podmaninstalled and working on the system.
make build-glibc-2.28
Run the application with an Ansible log file as an argument:
./ansible-logs-view /path/to/ansible-log-file.log
Or run with debug mode enabled:
./ansible-logs-view --debug /path/to/ansible-log-file.log
↑/↓: Navigate through tasksEnter/Space: Expand/collapse selected task and show full raw task text in separate panelPgUp/PgDn: Scroll details panel when visibleg: Go to the top of the task listG: Go to the bottom of the task list/: Toggle filter inputq/Ctrl+C: Quit the application
- Press
/to open the filter input - Type your search term (any part of task description, status, date, host, path, or diff content)
- Press
Enterto apply the filter - Press
Escto cancel filtering and restore all tasks
- Navigate to a task using arrow keys
- Press
EnterorSpaceto expand the selected task - View full raw task text in the separate details panel at the bottom (fixed to 1/3 of screen height)
- Use
PgUp/PgDnto scroll through long content in the details panel - Press
EnterorSpaceagain to collapse the task and hide details panel
The application now creates a debug.log file that contains detailed information about each parsed task, including:
- Task ID
- Description
- Status
- Host
- Path
- Start time
- Diff information
- First 1000 characters of RawText
To enable debug logging, run the application with the --debug flag:
./ansible-logs-view --debug /path/to/ansible-log-file.log
- Go 1.25.3+
- Bubbletea v1.3.10
- Bubbles v0.21.0
ansible-logs-view/
├── go.mod
├── go.sum
├── cmd/
│ ├── ansible-logs-view/
│ │ ├── main.go # Application entry point
│ │ └── ...
│ └── tui-poc/
│ ├── itemreader.go
│ └── main.go # Proof of concept TUI (not the main app)
├── internal/
│ └── app/
│ ├── logger.go # Logging setup
│ ├── parser_test.go # Parser tests
│ ├── parser.go # Log file parsing logic
│ ├── task.go # Task data structure
│ └── tui.go # Terminal user interface implementation
└── testdata/
├── sample.log
└── testitems.txt
To build the application:
go build -o ansible-logs-view ./cmd/ansible-logs-view
You can build the tool for an older RHEL/OL/Rockylinux with glibc-2.28 using ./build-glibc-2.28.sh. To run this script you need podman. It will download a rockylinux:8 image, build the tool there, spin a container pull the compiled binary to your host machine.
To run tests:
go test ./...
- Parses Ansible log files to extract individual tasks
- Extracts task metadata including:
- Task ID
- Description
- Start time
- Status (ok, changed, skipping, failed)
- Host
- Path
- Diff information
- Raw task text from the log file
- Debug logging: Creates debug.log file with detailed information about each parsed task
- Defines the
Taskstruct to represent parsed tasks - Contains all relevant task information for display including diff data and raw task text
- Centralized logging implementation for debug output
- Manages debug log file creation and writing
- Thread-safe logger initialization
- Implements a scrollable list view with viewport-based scrolling
- Provides dual-panel display:
- Task List Panel: Shows all tasks in a scrollable list with color-coded status indicators
- Details Panel: Displays full raw task text for expanded tasks
- Details panel properties:
- Fixed height to 1/3 of the screen
- Fixed width to full screen width
- Content wraps if lines are too long
- Scrollable with PgUp/PgDn keys
- Provides intuitive keyboard navigation:
- Arrow keys for navigation
- Enter/Space to expand/collapse tasks and show full raw task text in separate panel
- PgUp/PgDn to scroll details panel when visible
- g/G for top/bottom navigation
/for filtering tasks- Q/Ctrl+C to quit
- Filtering capability to search tasks by description, status, date, host, path, or diff content
- Color-coded status indicators for quick visual identification
- Handles command-line argument parsing
- Initializes the parser and TUI components
- Manages the application lifecycle
- Supports a
--debugflag to enable debug logging
- Contains integration-style tests for the parser
- Verifies that the parser correctly extracts task information
- Tests against sample log files to ensure correctness
Through careful analysis of the Ansible log file, the following patterns were identified:
- Tasks begin with
TASK [description] *****headers - Each task contains metadata including timestamps and paths
- Task execution status is indicated by lines like
ok:,changed:,skipping:, orfailed: - Timestamps follow the format:
DayOfWeek Day Month Year HH:MM:SS - Diff information appears in sections starting with
--- before: - Tasks with changes include detailed diff output showing before/after comparisons
- Color Coding: Different status types are visually distinguished with appropriate colors:
- Green for successful tasks (
ok) - Orange for tasks that made changes (
changed) - Gray for skipped tasks (
skipping) - Red for failed tasks (
failed)
- Green for successful tasks (
- Responsive Layout: The interface adapts to terminal window size changes
- Clear Navigation: Intuitive keyboard controls with visual feedback
- Dual-Panel Display: Task list and raw task text shown simultaneously
- Viewport Scrolling: Efficient handling of large numbers of tasks
- Search/Filter: Quick access to specific tasks by keyword
- Quick Analysis: Rapidly identify which tasks executed successfully, changed systems, or failed
- Change Tracking: Easily see exactly what files were modified by each task
- Troubleshooting: Quickly pinpoint problematic tasks and understand their impact
- Task Filtering: Find specific tasks by description, status, date, or other criteria
- Deployment Verification: Confirm that deployments executed as expected
- Audit Trail: Maintain a clear record of system changes
- Issue Resolution: Speed up debugging by focusing on specific task changes
- Learning Tool: Understand how Ansible tasks affect system state
- Code Review: Examine the actual changes made by deployment scripts
- Documentation: Use the tool to document deployment behaviors
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
