Skip to content

Commit be604b8

Browse files
committed
linux-mirror: add formatted output for mirror-status display
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 Link: https://patch.msgid.link/[email protected] Signed-off-by: Daniel Gomez <[email protected]>
1 parent 0f7fe7f commit be604b8

File tree

1 file changed

+20
-6
lines changed
  • playbooks/roles/linux-mirror/tasks

1 file changed

+20
-6
lines changed

playbooks/roles/linux-mirror/tasks/main.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,20 @@
214214
when:
215215
- not install_only_git_daemon|bool
216216

217-
- name: Service status
217+
- name: Display mirror service status
218218
ansible.builtin.debug:
219-
msg: "{{ item.status.ActiveState }}"
220-
loop: "{{ mirror_service_status.results }}"
219+
msg: |
220+
{% for result in mirror_service_status.results %}
221+
Mirror: {{ result.item.short_name }}
222+
Service: {{ result.item.short_name | regex_replace('/', '-') }}-mirror.service
223+
State: {{ result.status.ActiveState }}
224+
Enabled: {{ result.status.UnitFileState }}
225+
{% endfor %}
221226
tags: ["mirror-status"]
222227
when:
223228
- not install_only_git_daemon|bool
229+
vars:
230+
ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.msg }}"
224231

225232
- name: Check systemd unit status for mirror timers
226233
become: true
@@ -238,13 +245,20 @@
238245
when:
239246
- not install_only_git_daemon|bool
240247

241-
- name: Service timer status
248+
- name: Display mirror timer status
242249
ansible.builtin.debug:
243-
msg: "{{ item.status.ActiveState }}"
244-
loop: "{{ mirror_timer_status.results }}"
250+
msg: |
251+
{% for result in mirror_timer_status.results %}
252+
Mirror: {{ result.item.short_name }}
253+
Timer: {{ result.item.short_name | regex_replace('/', '-') }}-mirror.timer
254+
State: {{ result.status.ActiveState }}
255+
Enabled: {{ result.status.UnitFileState }}
256+
{% endfor %}
245257
tags: ["mirror-status"]
246258
when:
247259
- not install_only_git_daemon|bool
260+
vars:
261+
ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.msg }}"
248262

249263
- name: Enable git service systemd socket activation
250264
become: true

0 commit comments

Comments
 (0)