In order to run java code I need to first set the classpath of dependent 
libraries by running a script setWLSEnv.sh as below:

$ . /app/wlserv*/server/bin/setWLSEnv.sh
$ java weblogic.version


The output gives me the version of the product which I need. 
I wrote the below playbook but it does not run the java code. 

---
  - hosts: dest_nodes


    tasks:
      - name: Get weblogic version
        shell: "/app/wlserv*/server/bin/setWLSEnv.sh;java weblogic.version"
        register: wlsversion


      - debug:
          msg: "{{ wlsversion }}"


However, I get this error:

fatal: [10.0.0.91]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "cmd": "/app/wlserv*/server/bin/setWLSEnv.sh;java weblogic.version",
    "delta": "0:00:00.271434",
    "end": "2020-05-15 16:31:44.209506",
    "invocation": {
        "module_args": {
            "_raw_params": "/app/wlserv*/server/bin/setWLSEnv.sh;java 
weblogic.version",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": true
        }
    },
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2020-05-15 16:31:43.938072",
    "stderr": "Error: Could not find or load main class weblogic.version",
    "stderr_lines": [
        "Error: Could not find or load main class weblogic.version"
    ],
    "stdout": 
"CLASSPATH=/usr/java/jdk1.8.0_192-amd64/lib/tools.jar:/app/wlserver/modules/features/wlst.wls.classpath.jar:\n\nPATH=/app/wlserver/server/bin:/app/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.9.8.0.0/apache-ant-1.9.8/bin:/usr/java/jdk1.8.0_192-amd64/jre/bin:/usr/java/jdk1.8.0_192-amd64/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/app/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin\n\nYour
 
environment has been set.",
    "stdout_lines": [
        
"CLASSPATH=/usr/java/jdk1.8.0_192-amd64/lib/tools.jar:/app/wlserver/modules/features/wlst.wls.classpath.jar:"
,
        "",
        
"PATH=/app/wlserver/server/bin:/app/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.9.8.0.0/apache-ant-1.9.8/bin:/usr/java/jdk1.8.0_192-amd64/jre/bin:/usr/java/jdk1.8.0_192-amd64/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/app/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin"
,
        "",
        "Your environment has been set."
    ]
}


>From the output, I see that the classpath did get set but java 
weblogic.version command failed on the remote host.

Can you please suggest how can I get the Weblogic version registered to 
wlsversion variable ?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f9e6d0f2-75a4-48ee-b086-ffb11a4e3336%40googlegroups.com.

Reply via email to