AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible reboot Module: Restart Hosts and Wait for Recovery (Complete Guide)

By Luca Berton · Published 2024-01-01 · Category: troubleshooting

How to use Ansible reboot module to safely restart servers. Wait for SSH, set timeout, handle kernel updates. Complete guide with playbook examples.

Ansible reboot Module: Restart Hosts and Wait for Recovery (Complete Guide)

The ansible.builtin.reboot module reboot a machine and wait for it to come back. This guide covers all common use cases with practical playbook examples.

Basic Reboot

Reboot with Custom Timeout

Conditional Reboot (Kernel Update)

Reboot and Verify Service

Check if Reboot is Required

FAQ

How do I reboot a server with Ansible?

Use ansible.builtin.reboot. It reboots the host and automatically waits for SSH to become available again before continuing with the next task.

How long does Ansible wait after a reboot?

By default, Ansible waits up to 600 seconds (10 minutes) for the host to come back. Adjust with reboot_timeout. Use post_reboot_delay to add extra wait time after SSH reconnects.

How do I check if a reboot is required in Ansible?

On Debian/Ubuntu, check if /var/run/reboot-required exists with ansible.builtin.stat. On RHEL, run needs-restarting -r and check the return code.

Conclusion

The ansible.builtin.reboot module is a versatile tool for reboot a machine and wait for it to come back. Use the examples above as starting points and adapt them to your infrastructure needs.

Related ArticlesAnsible service Module: Manage ServicesAnsible wait_for Module

Category: troubleshooting

Browse all Ansible tutorials · AnsiblePilot Home