From b4b965259adc7c6c6d6c8628b13ec3ca6914219a Mon Sep 17 00:00:00 2001 From: Danny de Kooker Date: Mon, 17 Jun 2024 09:00:30 +0200 Subject: [PATCH] added consolidation on the notification --- Testing/maint-reboot-required-notify.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Testing/maint-reboot-required-notify.yaml b/Testing/maint-reboot-required-notify.yaml index 5c3d713..60f2155 100644 --- a/Testing/maint-reboot-required-notify.yaml +++ b/Testing/maint-reboot-required-notify.yaml @@ -25,13 +25,21 @@ results: > {{ 'Reboot required on ' ~ inventory_hostname ~ ' with reboot status: ' ~ (reboot.stat.exists | ternary('True', 'False')) }} + - name: Consolidate results + set_fact: + consolidated_results: "{{ consolidated_results | default([]) + [results] }}" + run_once: true + delegate_to: localhost + - name: Send notification to Teams uri: url: "{{ Teams_webhook }}" method: POST body: | { - "text": "{{ results }}" + "text": "{{ '\n'.join(consolidated_results) }}" } body_format: json - # when: reboot.stat.exists \ No newline at end of file + run_once: true + delegate_to: localhost + when: consolidated_results | length > 0 \ No newline at end of file