ansiblebit/oracle-java

RedHat/Amazon Linux: role fails when setting Java version as default

kevinchabreck opened this issue · 6 comments

TASK [ansiblebit.oracle-java : set Java version as default] *******************************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|changed` instead use `result is changed`. This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
failed: [xx.xx.xx.xx] (item={'path': '/usr/java/jdk1.8.0_171/jre/bin', 'exe': 'java'}) => {"changed": false, "item": {"exe": "java", "path": "/usr/java/jdk1.8.0_171/jre/bin"}, "msg": "Specified path /usr/java/jdk1.8.0_171/jre/bin/java does not exist"}
failed: [xx.xx.xx.xx] (item={'path': '/usr/java/jdk1.8.0_171/jre/bin', 'exe': 'keytool'}) => {"changed": false, "item": {"exe": "keytool", "path": "/usr/java/jdk1.8.0_171/jre/bin"}, "msg": "Specified path /usr/java/jdk1.8.0_171/jre/bin/keytool does not exist"}
failed: [xx.xx.xx.xx] (item={'path': '/usr/java/jdk1.8.0_171/bin', 'exe': 'javac'}) => {"changed": false, "item": {"exe": "javac", "path": "/usr/java/jdk1.8.0_171/bin"}, "msg": "Specified path /usr/java/jdk1.8.0_171/bin/javac does not exist"}
failed: [xx.xx.xx.xx] (item={'path': '/usr/java/jdk1.8.0_171/bin', 'exe': 'javadoc'}) => {"changed": false, "item": {"exe": "javadoc", "path": "/usr/java/jdk1.8.0_171/bin"}, "msg": "Specified path /usr/java/jdk1.8.0_171/bin/javadoc does not exist"}

When running this role on Amazon Linux (which is based on RHEL) the role fails during the set Java version as default task. It seems to be using the wrong path for the java installation directory (/usr/java/jdk1.8.0_171) rather than the correct path (/usr/java/jdk1.8.0_171-amd64).

I ran this role using the default configuration.

roles:
  - name: install Oracle JDK 8
    role: ansiblebit.oracle-java
    oracle_java_set_as_default: yes

I'm facing this issue as well and I believe the issue is that something changed on Oracle's end last weekend. As a temporary fix I've resorted to adding a symlink from /usr/java/jdk1.8.0_171 to /usr/java/jdk1.8.0_171-amd64 before running this role.

Changing the oracle_java_home default to /usr/java/jdk-{{ oracle_java_version }}-amd64 (i.e., adding -amd64) is another possible fix.

running on centos7, i'm now seeing this problem as well.

$ ls -l /usr/java/
lrwxrwxrwx. 1 root root  16 May 10 17:41 default -> /usr/java/latest
drwxr-xr-x. 9 root root 268 May 10 17:41 jdk1.8.0_171-amd64
lrwxrwxrwx. 1 root root  28 May 10 17:41 latest -> /usr/java/jdk1.8.0_171-amd64

I tried to override {{oracle_java_home}} today and it took quite a bit of digging why I couldn't at first so if anyone else had trouble overriding this here is what I found:

The role does an include_vars with the file in the default dir. Which puts it rather high on the override precedence. There are only two places where you can override oracle_java_home while still referencing oracle_java_version_update (for keeping the dynamic update version):

ansible-playbook -e oracle_java_home="/usr/java/jdk1.{{ oracle_java_version }}.0_{{ oracle_java_version_update }}-amd64"
and in your playbook as a role variable:

roles:
- role: oracle-java
  oracle_java_home: "/usr/java/jdk1.{{ oracle_java_version }}.0_{{ oracle_java_version_update }}-amd64"

I've checked a JDK 10.0.2 installation on CentOS 7 and this seems to be the way to set a proper default for Java in these systems (thank you @ardentperf).

I've changed the default value of oracle_java_home for RedHat distributions to /usr/java/default' on the develop branch.
hopefully, people will need to do less changes this way.

fixed on https://github.com/ansiblebit/oracle-java/releases/tag/6.22.0.

please report any new problems you may find.

thank you!