--- - name: get uptime in min shell: awk '{printf "%0.f", $0/60}' /proc/uptime register: uptime - name: Reboot server shell: "sleep 5 && /sbin/reboot" async: 1 poll: 0 become: true when: uptime > 30 - name: Wait for the reboot to complete wait_for_connection: connect_timeout: 20 sleep: 5 delay: 5 timeout: 300 when: uptime > 30