--- - name: Apply all Linux updates hosts: all become: yes tasks: - name: Update all packages package: name: "*" state: latest register: update_result - name: Reboot if kernel updated reboot: when: update_result.changed