--- - hosts: all tasks: - stat: path: /run/reboot-required register: st - debug: msg: Reboot required. when: st.stat.exists