My ansible role does the following:
-
create user weblogic with bash and homedir in group weblogic
-
Unpacks jdk into an oracle_home dir, owned by weblogic user
And finally:
- name: Set
become: true
become_user: weblogic
set_fact:
newpath: "{{JAVA_HOME}}/bin:{{lookup('ansible.builitin.env', 'PATH')}}"
So newpath is
"/opt/oracle/jdk1.8.0_431/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
My issue is with this task:
- name : Validate Java
become: true
become_user: weblogic
command: "java -version"
environment:
JAVA_HOME: "{{JAVA_HOME}}"
PATH: "{{newpath}}"
register: javaver
On ubuntu 24 I get the java installed in /usr/bin/java
On SUSE SLES15 i get the wanted java
I checked directly as user weblogic on both hosts:
export JAVA_HOME=/opt/oracle/jdk1.8.0_431
export PATH="/opt/oracle/jdk1.8.0_431/bin:$PATH"
java -version
On ubuntu host:
bash: /opt/oracle/jdk1.8.0_431/bin/java: No such file or directory
On SUSE:
java version “1.8.0_431”