Reboot and wait until server is reachable/usable:

- name: Something that may reboot
  shell: echo "true"
  register: should_reboot

- name: Rebooting ...
  shell: sleep 2 && /sbin/shutdown -r now "Reboot required"
  async: 1
  poll: 0
  ignore_errors: true
  register: rebooting
  when: should_reboot.stdout == "true"

- name: Wait for rebooted servers to come back
  wait_for_connection:
    connect_timeout: 20
    sleep: 5
    delay: 5
    timeout: 60
  when: rebooting|changed

For checking/testing if a remote host/service is up:

- name: Wait for service to be ready
  wait_for:
    port: 8080
    host: 127.0.0.1
    connect_timeout: 3
    delay: 3
    timeout: 30