diff --git a/Maintenance/maint-reboot-required.yaml b/Maintenance/maint-reboot-required.yaml index 990e410..50aacf3 100644 --- a/Maintenance/maint-reboot-required.yaml +++ b/Maintenance/maint-reboot-required.yaml @@ -23,13 +23,9 @@ - name: Wait for systems to become reachable wait_for_connection: - - name: Gather server information + - name: Get list of rebooted servers set_fact: - server_info: "{{ { 'server': inventory_hostname, 'rebooted': reboot.stat.exists } }}" - - - name: Create a list of server information - set_fact: - server_list: "{{ server_list | default([]) + [server_info] }}" + rebooted_servers: "{{ groups['all'] | intersect(reboot.results | selectattr('stat.exists') | map(attribute='ansible_host')) }}" - name: Send Teams notification run_once: true @@ -39,25 +35,9 @@ body: | { "title": "Playbook: {{ ansible_play_name }}", - "text": "All servers were checked and rebooted where needed.", - "sections": [ - { - "activityTitle": "Server Reboot Status", - "facts": [ - { - "name": "Server", - "value": "{{ server_list | map(attribute='server') | join(', ') }}" - }, - { - "name": "Rebooted", - "value": "{{ server_list | map(attribute='rebooted') | map('string') | join(', ') }}" - } - ], - "markdown": true - } - ] + "text": "The following servers were rebooted: {{ rebooted_servers | join(', ') }}" } body_format: json headers: Content-Type: application/json - when: reboot.stat.exists or not reboot.stat.exists \ No newline at end of file + when: rebooted_servers | length > 0 \ No newline at end of file