Hello DevOps enthusiasts! Here I came up with new learning on the automations with Ansible reboot module on a VM/Linux server. This is a most common requirement for most DevOps projects having the dev, test, stage, production environments, when there is Operating System patching happens on a VM, there could be a need for the reboot of that VM
Ansible reboot module and its parameters |
There are reboot strategy is most important in how you handle the box before reboot and after reboot.
- You must aware of all the manual processes that will be required to start after reboot.
- During the reboot select the proper timeout in seconds.
- If "systemd" started as a service you can check the major/important service status to show it as 'active'
Pre-requisites
To execute the following experiment you must have the following setup:
- Ansible Controller
- Managed nodes (multiple) defined in the inventory and accessible for running playbooks
Ansible playbook for reboot VM
In this example playbook, I've used CentOS 7 VM for testing the reboot module.
--- - name: Linux Reboot Demo hosts: web gather_facts: no become: true tasks: - name: Reboot the machine (Wait for a minute) reboot: reboot_timeout: 60 - name: Check the Uptime of the servers shell: "uptime" register: Uptime - debug: msg: "{{ Uptime.stdout }}"
Post reboot - once the reboot is completed there will be a couple of services that will be automatically launched, For that we can do validation for the specific process with a task in the playbook.
In some cases, you may need to validate the application sanity health check for the web URL. which I"ve experimented and posted separately using URI module.
Execution of the above playbook for the reboot of web VMs snap Image here
Official Documentation link for reboot module
Official Documentation link for reboot module
No comments:
Post a Comment