test
This commit is contained in:
@@ -23,13 +23,9 @@
|
|||||||
- name: Wait for systems to become reachable
|
- name: Wait for systems to become reachable
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
|
|
||||||
- name: Gather server information
|
- name: Get list of rebooted servers
|
||||||
set_fact:
|
set_fact:
|
||||||
server_info: "{{ { 'server': inventory_hostname, 'rebooted': reboot.stat.exists } }}"
|
rebooted_servers: "{{ groups['all'] | intersect(reboot.results | selectattr('stat.exists') | map(attribute='ansible_host')) }}"
|
||||||
|
|
||||||
- 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
|
||||||
@@ -39,25 +35,9 @@
|
|||||||
body: |
|
body: |
|
||||||
{
|
{
|
||||||
"title": "Playbook: {{ ansible_play_name }}",
|
"title": "Playbook: {{ ansible_play_name }}",
|
||||||
"text": "All servers were checked and rebooted where needed.",
|
"text": "The following servers were rebooted: {{ rebooted_servers | join(', ') }}"
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
body_format: json
|
body_format: json
|
||||||
headers:
|
headers:
|
||||||
Content-Type: application/json
|
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