---
# update packages to latest

- name: run apt updates
  apt:
    upgrade: dist
    update_cache: yes
    cache_valid_time: 3600
    autoremove: yes
  when: ansible_os_family == "Debian"

- name: check for reboot required
  stat:
    path: /var/run/reboot-required
  register: reboot_required

- name: reboot after updates
  reboot:
  when: reboot_required.stat.exists
