--- - name: Prepare hosts: all tasks: - name: Ensure apt cache is updated ansible.builtin.apt: update_cache: true when: ansible_pkg_mgr == 'apt'