--- - name: Update the apt cache, if needed apt: update_cache=yes when: openjdk_pkg_state == 'latest' tags: jdk - name: install OpenJDK JRE apt: pkg=openjdk-{{ item.0 }}-{{ item[1] }} state={{ openjdk_pkg_state }} with_nested: - '{{ openjdk_version }}' - [ 'jre', 'jre-headless', 'jdk' ] notify: Set the default OpenJDK tags: jdk - name: Set fact jdk_installed set_fact: jdk_installed=true tags: jdk