Instead of parsing raw stdout, you can use the JSON files in the job_events directory to programmatically process Ansible execution details. Runner assigns order to these events and includes the associated stdout and line numbers for each event.
Key event types include:
playbook_on_task_start: Emitted when a task begins.playbook_on_stats: The final event emitted if a playbook runs to completion without being killed, containing the PLAY RECAP data.
Each event JSON object typically includes:
uuid: Unique identifier for the event.event: The type of event (e.g., playbook_on_task_start).event_data: Metadata specific to the event (e.g., task_uuid, playbook, task_args).stdout: The relevant portion of stdout for that event.start_line / end_line: The line range in the stdout file.created: Timestamp of the event.
{
"uuid": "8c164553-8573-b1e0-76e1-000000000008",
"parent_uuid": "xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx",
"counter": 5,
"stdout": "\r\nTASK [debug] *******************************************************************",
"start_line": 5,
"end_line": 7,
"event": "playbook_on_task_start",
"event_data": {
"playbook": "test.yml",
"playbook_uuid": "34437b34-addd-45ae-819a-4d8c9711e191",
"play": "all",
"play_uuid": "8c164553-8573-b1e0-76e1-000000000006",
"play_pattern": "all",
"task": "debug",
"task_uuid": "8c164553-8573-b1e0-76e1-000000000008",
"task_action": "debug",
"task_path": "\/home\/mjones\/ansible\/ansible-runner\/demo\/project\/test.yml:3",
"task_args": "msg=Test!",
"name": "debug",
"is_conditional": false,
"pid": 10640
},
"pid": 10640,
"created": "2018-06-07T14:54:58.410605"
}