Ansible - reboot module

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).


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
    - name: reboot OS
        msg: "Reboot initiated by Ansible"
        connect_timeout: 5
        reboot_timeout: 600
        pre_reboot_delay: 0
        post_reboot_delay: 30
        test_command: whoami


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |