--- - name: Reboot all hosts hosts: all gather_facts: false tasks: - name: Reboot host ansible.builtin.reboot: reboot_timeout: 900 connect_timeout: 10 pre_reboot_delay: 0 post_reboot_delay: 30 test_command: whoami register: reboot_result - name: Report reboot status ansible.builtin.set_fact: reboot_report: host: "{{ inventory_hostname }}" rebooted: true elapsed: "{{ reboot_result.elapsed | default('unknown') }}" - name: Reboot summary hosts: localhost gather_facts: false tasks: - name: Display reboot report ansible.builtin.debug: msg: | ========================== REBOOT SUMMARY ========================== {% for host in groups['all'] %} Host: {{ host }} Status: Reboot successful Time until back online: {{ hostvars[host].reboot_report.elapsed }} seconds {% endfor %}