2
0
This commit is contained in:
2024-06-08 14:57:48 +02:00
parent c9caaa6a67
commit c8e0e229a8

View File

@@ -23,6 +23,14 @@
- name: Wait for systems to become reachable - name: Wait for systems to become reachable
wait_for_connection: wait_for_connection:
- name: Gather server information
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] }}"
- name: Send Teams notification - name: Send Teams notification
run_once: true run_once: true
uri: uri:
@@ -32,13 +40,21 @@
{ {
"title": "Playbook: {{ ansible_play_name }}", "title": "Playbook: {{ ansible_play_name }}",
"text": "All servers were checked and rebooted where needed.", "text": "All servers were checked and rebooted where needed.",
"facts": [ "sections": [
{% for host in ansible_play_hosts_all %}
{ {
"name": "{{ host }}", "activityTitle": "Server Reboot Status",
"value": "{% if hostvars[host]['reboot'] is defined and hostvars[host]['reboot'].stat.exists %}&#U+2705 Rebooted{% else %}Not Rebooted{% endif %}" "facts": [
}{% if not loop.last %},{% endif %} {
{% endfor %} "name": "Server",
"value": "{{ server_list | map(attribute='server') | join(', ') }}"
},
{
"name": "Rebooted",
"value": "{{ server_list | map(attribute='rebooted') | map('string') | join(', ') }}"
}
],
"markdown": true
}
] ]
} }
body_format: json body_format: json