Logo

Personal Ops Runbook

Personal runbook covering infrastructure operations for Cloud, Kubernetes, OpenStack, and Ceph environments. Includes deployment and teardown procedures, node management, cluster monitoring setup, and incident response workflows compiled from day-to-day operational work. Intended strictly for personal reference — configurations and scripts are environment-specific and not guaranteed to work as-is elsewhere.

[Ansible] Reboot remote server


Để khởi động lại một server từ xa (remote server) trong Ansible, bạn có thể sử dụng module reboot.

Ví dụ, để khởi động lại tất cả các server trong inventory, bạn có thể sử dụng playbook sau:

- name: Reboot all servers
  hosts: all
  become: true

  tasks:
    - name: Reboot server
      reboot:
        reboot_timeout: 300
        pre_reboot_delay: 0
        post_reboot_delay: 30

Trong đoạn mã này, task Reboot server sẽ sử dụng module reboot để khởi động lại server. Module reboot cho phép bạn định cấu hình thời gian chờ trước khi khởi động lại (pre_reboot_delay), thời gian chờ sau khi khởi động lại (post_reboot_delay) và thời gian tối đa để chờ đợi cho quá trình khởi động lại (reboot_timeout).

Lưu ý rằng khi sử dụng module reboot, Ansible sẽ thực hiện các task tiếp theo trên một phiên bản khác của server sau khi server được khởi động lại.