From f2bc548e02dc806b69dc57e2a76adf1942af489a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 24 Mar 2024 14:17:05 +0000 Subject: [PATCH] Set correct path to java executable for java 11+ --- roles/install_java/tasks/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/install_java/tasks/main.yml b/roles/install_java/tasks/main.yml index cc620f5d..880873ca 100644 --- a/roles/install_java/tasks/main.yml +++ b/roles/install_java/tasks/main.yml @@ -16,8 +16,21 @@ path: "/usr/lib/jvm/{{ java_package }}" register: java_package_info +- name: Check if JRE exists + ansible.builtin.stat: + path: "{{ java_package_info.stat.lnk_source }}/jre" + register: java_jre + - name: Set the default java version - {{ java_package_info.stat.lnk_source }} community.general.alternatives: name: java path: "{{ java_package_info.stat.lnk_source }}/jre/bin/java" state: selected + when: java_jre.stat.exists + +- name: Set the default java version - {{ java_package_info.stat.lnk_source }} + community.general.alternatives: + name: java + path: "{{ java_package_info.stat.lnk_source }}/bin/java" + state: selected + when: not java_jre.stat.exists