Using OFMW 12c global variables in automating upgrades with Ansible
Automating OFMW 12c patches and upgrades with Ansible gives you a chance to find a lot more about the peculiarities of Oracle Fusion Middleware implementation.
One of the recent discoveries I have made while automating JDK replacement for 12c R2 (12.2.1.3+) line of products is the central location of JAVA_HOME variable. If you plan to store your JDK in a new directory and use a symbolic link to point to the new location, you might be in trouble. Specifying JAVA_HOME as a symbolic link is not certified/tested with Oracle WebLogic Server, and it’s not mentioned in any documents. If you keep the older JDK directory, you won’t even discover anything. However, simple deletion of older JDK will cripple your wlst.sh and other scripts from $ORACLE_HOME/oracle_common/common/bin
The JAVA_HOME environment variable is centrally located in $ORACLE_HOME/oui/.globalEnv.properties and is updated upon installation, as well as during patching.
One of the possible solutions to handle it when automating JDK upgrade with Ansible would be using lineinfile module.
- name: Update JAVA_HOME variable in the .globalEnv.properties file
lineinfile:
path: "{{ oracle_home }}/oui/.globalEnv.properties"
regexp: '^(.*)JAVA_HOME=(.*)$'
line: "JAVA_HOME={{ oracle_home }}"/java/jdk{{ jdk_version }}
- name: Update JAVA_HOME variable in the .globalEnv.properties file
lineinfile:
path: "{{ oracle_home }}/oui/.globalEnv.properties"
regexp: '^(.*)JAVA_HOME=(.*)$'
line: "JAVA_HOME_1_8={{ oracle_home }}"/java/jdk{{ jdk_version }}
oracle_home variable value in this example would be your FMW product installation directory.
jdk_version variable value example could be: “1.8.0_241”.
You can use a similar approach to update other files under $ORACLE_HOME/oui/bin directory.
One additional benefit you can get from scripts in $ORACLE_HOME/oui/bin directory for automation with Ansible is using viewInventory.sh script to determine a version of your product distribution.
Consider the following example where you can store the version into prod_check variable:
---
- name: Checking distribution
hosts: soa
vars:
oracle_home: "/u01/app/oracle/product/fmw12c"
fmw_product: "SOA"
tasks:
- name: Check installed version
shell: "{{ oracle_home }}/oui/bin/viewInventory.sh | grep 'Distribution' | awk '/{{ fmw_product }}/ {print $3}'"
register: prod_check
- debug: var=prod_check.stdout
...