---
- name: Check if a reboot is needed on all servers
  register: reboot_required_file
  stat: path=/var/run/reboot-required get_md5=no

- name: Reboot the box if kernel updated
  reboot:
    msg: "Reboot initiated by Ansible for kernel updates"
    connect_timeout: 5
    reboot_timeout: 300
    pre_reboot_delay: 0
    post_reboot_delay: 30
    test_command: uptime
  throttle: 1
  when: reboot_required_file.stat.exists
