Initial Lab Setup
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- name: Managed Reboot of Lab Infrastructure
|
||||
hosts: all_nodes
|
||||
become: true
|
||||
gather_facts: true
|
||||
serial: 3 # Reboots one host at a time to maintain availability
|
||||
|
||||
tasks:
|
||||
- name: Check if reboot is actually required
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/reboot-required
|
||||
register: reboot_required_file
|
||||
|
||||
- name: Reboot block
|
||||
when: reboot_required_file.stat.exists
|
||||
block:
|
||||
- name: Handle Proxmox Guests (Endor specific)
|
||||
when: inventory_hostname == 'endor'
|
||||
shell: |
|
||||
# Gracefully stop all running VMs/CTs that aren't set to autostart
|
||||
# or simply rely on Proxmox's built-in shutdown service.
|
||||
# This is a safety check.
|
||||
pvesh create /nodes/localhost/stopall
|
||||
register: stop_all_guests
|
||||
failed_when: false
|
||||
|
||||
- name: Reboot the machine
|
||||
ansible.builtin.reboot:
|
||||
msg: "Reboot initiated by Ansible for kernel updates"
|
||||
connect_timeout: 5
|
||||
reboot_timeout: 600
|
||||
pre_reboot_delay: 10
|
||||
post_reboot_delay: 30
|
||||
test_command: uptime
|
||||
|
||||
- name: Confirm uptime
|
||||
ansible.builtin.debug:
|
||||
msg: "Host {{ inventory_hostname }} is back up and running."
|
||||
|
||||
- name: No reboot needed
|
||||
ansible.builtin.debug:
|
||||
msg: "Host {{ inventory_hostname }} does not require a reboot."
|
||||
when: not reboot_required_file.stat.exists
|
||||
|
||||
Reference in New Issue
Block a user