initial commit
This commit is contained in:
33
Testing/maint-reboot-required-notify.yaml
Normal file
33
Testing/maint-reboot-required-notify.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: Check if system reboot is required with teams notification
|
||||
hosts: all
|
||||
become: yes
|
||||
become_user: root
|
||||
|
||||
tasks:
|
||||
- name: Check if a reboot is required
|
||||
register: reboot
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/reboot-required
|
||||
|
||||
- name: Reboot machine
|
||||
ansible.builtin.reboot:
|
||||
when: reboot.stat.exists
|
||||
|
||||
- name: Wait for systems to become reachable
|
||||
wait_for_connection:
|
||||
delay: 5
|
||||
timeout: 300
|
||||
|
||||
- name: Collect results
|
||||
set_fact:
|
||||
results: >
|
||||
{{ 'Reboot required on ' inventory_hostname + 'ith reboot status: ' (reboot.stat.exists | ternary('True', 'False')) }}
|
||||
|
||||
- name: Send notification to Teams
|
||||
uri:
|
||||
url: "{{ Teams_webhook }}"
|
||||
method: POST
|
||||
body: "{{ results }}"
|
||||
body_format: json
|
||||
when: reboot.stat.exists
|
||||
Reference in New Issue
Block a user