Bootstrap FreeKB - Ansible - Reboot a system
Ansible - Reboot a system

Updated:   |  Ansible articles

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

The reboot module, as the name suggests, can be reboot a managed nodes operating system. In this example, 30 seconds after the reboot was initiated, there will be an attempt to SSH onto the host and issue the whoami command to see if the host is up, keeping this up for 600 seconds (10 minutes).AVOID TROUBLE

The reboot module can only be run by root or by a user or group that has been granted sudo permission to the reboot command, because the reboot command is within the sbin directory (e.g. /usr/sbin/reboot). Refer to Ansible - become (sudo) for the steps on how to grant a user or group become (sudo) permission to the reboot command.

---
- hosts: all
  tasks:
  - name: reboot OS
    reboot:
      msg: "Reboot initiated by Ansible"
      connect_timeout: 5
      reboot_timeout: 600
      pre_reboot_delay: 0
      post_reboot_delay: 30
      test_command: whoami
...

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ae99f5 in the box below so that we can be sure you are a human.