test
This commit is contained in:
@@ -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
|
||||
when: rebooted_servers | length > 0
|
||||
Reference in New Issue
Block a user