added consolidation on the notification
This commit is contained in:
@@ -25,13 +25,21 @@
|
|||||||
results: >
|
results: >
|
||||||
{{ 'Reboot required on ' ~ inventory_hostname ~ ' with reboot status: ' ~ (reboot.stat.exists | ternary('True', 'False')) }}
|
{{ '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
|
- name: Send notification to Teams
|
||||||
uri:
|
uri:
|
||||||
url: "{{ Teams_webhook }}"
|
url: "{{ Teams_webhook }}"
|
||||||
method: POST
|
method: POST
|
||||||
body: |
|
body: |
|
||||||
{
|
{
|
||||||
"text": "{{ results }}"
|
"text": "{{ '\n'.join(consolidated_results) }}"
|
||||||
}
|
}
|
||||||
body_format: json
|
body_format: json
|
||||||
# when: reboot.stat.exists
|
run_once: true
|
||||||
|
delegate_to: localhost
|
||||||
|
when: consolidated_results | length > 0
|
||||||
Reference in New Issue
Block a user