Monday, August 30, 2021

How to reboot the nodes in OCI using ansible.

---
- hosts:  node list
  become: yes

  tasks:
   - name: Check the uptime
     shell: uptime
     register: UPTIME_PRE_REBOOT

   - debug: msg={{UPTIME_PRE_REBOOT.stdout}}
  
   - name: Check the kernel info before the reboot
     shell: uname -a
     register: Kernel_PRE_REBOOT

   - debug: msg={{Kernel_PRE_REBOOT.stdout}}

   - name: Unconditionally reboot the machine with all defaults
     reboot:
       reboot_timeout: 600

   - name: Check the uptime after reboot
     shell: uptime
     register: UPTIME_POST_REBOOT

   - debug: msg={{UPTIME_POST_REBOOT.stdout}}
 
   - name: Check the kernel info after the reboot
     shell: uptrack-uname -a
     register: Kernel_POST_REBOOT
  
   - debug: msg={{Kernel_POST_REBOOT.stdout}}

No comments:

Post a Comment