-
Notifications
You must be signed in to change notification settings - Fork 2
/
patch-weblogic.yml
50 lines (45 loc) · 1.94 KB
/
patch-weblogic.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
- name: Fail if required weblogic patch variables not defined
fail:
msg: "Error, please ensure weblogic_patch_filename and weblogic_patch_ids are defined"
when: weblogic_patch_filename is not defined or weblogic_patch_id is not defined
- name: Get current weblogic patch
become_user: oracle
ansible.builtin.shell: |
. ~/.bash_profile > /dev/null
. $WL_HOME/server/bin/setWLSEnv.sh > /dev/null
cd $WL_HOME/../utils/bsu/
./bsu.sh -view -status=applied -prod_dir=$WL_HOME | grep "^Patch ID:" | cut -d: -f2 | sed 's/^ *//g' | cut -d\ -f1 | tr "\n" " "
check_mode: false
changed_when: false
register: weblogic_existing_patch
- name: Set existing weblogic patch code fact
set_fact:
weblogic_existing_patch_code: "{{ weblogic_existing_patch.stdout }}"
- name: Install weblogic patch
when: not weblogic_existing_patch_code is search(weblogic_patch_id)
block:
- name: Remove previous patch files
ansible.builtin.file:
path: "{{ weblogic_patch_filename.split('/')[:-1] | join('/') }}"
state: absent
- import_tasks: extract-s3-archive.yml
vars:
weblogic_s3_archives:
- "{{ weblogic_patch_filename }}"
# takes forever so run in async mode to prevent connection timeouts
- name: Run weblogic patch script which takes approx 20 mins
become_user: oracle
ansible.builtin.shell: |
set -eo pipefail
. ~/.bash_profile
. $WL_HOME/server/bin/setWLSEnv.sh
main() {
patch_dir={{ weblogic_patch_filename.split('/')[:-1] | join('/') }}
echo "Install patch: ./bsu.sh -install -patch_download_dir=$patch_dir -patchlist={{ weblogic_patch_id }} -prod_dir=$WL_HOME -verbose"
cd $WL_HOME/../utils/bsu/
./bsu.sh -install -patch_download_dir=$patch_dir -patchlist={{ weblogic_patch_id }} -prod_dir=$WL_HOME -verbose
}
main 2>&1 | logger -p local3.info -t ansible-weblogic
async: 3600
poll: 60