- hosts: all tasks: - name: Upgrade packages. become: yes apt: update_cache: yes upgrade: full autoremove: yes purge: yes autoclean: yes - name: Check for /run/reboot-required. stat: path: /run/reboot-required no_log: true register: st - debug: msg: Reboot required. when: st.stat.exists