[PATCH 12/12] linux-mirror: add formatted output for mirror-status display
Daniel Gomez <[email protected]> Thu, 06 Nov 2025 23:36:06 +0100
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> The mirror-status tasks were showing only the ActiveState value in a loop, which provided minimal information and did not work properly with the community.general.diy callback plugin. The diy callback displays "All items completed" for Ansible loops instead of showing the actual status data, making the output useless for monitoring mirror status. Replaced the simple debug output with formatted multiline messages that display comprehensive status information for each mirror including the mirror name, service or timer unit name, active state, and enabled status. Changed both tasks from Ansible loops to Jinja2 template loops within the debug message so each task runs once and generates a single formatted message containing all mirror statuses. Added ansible_callback_diy_runner_on_ok_msg variable to both display tasks to enable proper integration with the diy callback plugin. This provides clean formatted output consistent with other kdevops status commands, making it easy to quickly scan the status of all git mirror repositories. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- playbooks/roles/linux-mirror/tasks/main.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/playbooks/roles/linux-mirror/tasks/main.yml b/playbooks/roles/linux-mirror/tasks/main.yml index 5f905fc0..6c4db4e3 100644 --- a/playbooks/roles/linux-mirror/tasks/main.yml +++ b/playbooks/roles/linux-mirror/tasks/main.yml @@ -214,13 +214,20 @@ when: - not install_only_git_daemon|bool -- name: Service status +- name: Display mirror service status ansible.builtin.debug: - msg: "{{ item.status.ActiveState }}" - loop: "{{ mirror_service_status.results }}" + msg: | + {% for result in mirror_service_status.results %} + Mirror: {{ result.item.short_name }} + Service: {{ result.item.short_name | regex_replace('/', '-') }}-mirror.service + State: {{ result.status.ActiveState }} + Enabled: {{ result.status.UnitFileState }} + {% endfor %} tags: ["mirror-status"] when: - not install_only_git_daemon|bool + vars: + ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.msg }}" - name: Check systemd unit status for mirror timers become: true @@ -238,13 +245,20 @@ when: - not install_only_git_daemon|bool -- name: Service timer status +- name: Display mirror timer status ansible.builtin.debug: - msg: "{{ item.status.ActiveState }}" - loop: "{{ mirror_timer_status.results }}" + msg: | + {% for result in mirror_timer_status.results %} + Mirror: {{ result.item.short_name }} + Timer: {{ result.item.short_name | regex_replace('/', '-') }}-mirror.timer + State: {{ result.status.ActiveState }} + Enabled: {{ result.status.UnitFileState }} + {% endfor %} tags: ["mirror-status"] when: - not install_only_git_daemon|bool + vars: + ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.msg }}" - name: Enable git service systemd socket activation become: true -- 2.51.0