diff --git a/ansible/roles/oasys-bip/defaults/main.yml b/ansible/roles/oasys-bip/defaults/main.yml index d3575b814..361c000ee 100644 --- a/ansible/roles/oasys-bip/defaults/main.yml +++ b/ansible/roles/oasys-bip/defaults/main.yml @@ -28,8 +28,10 @@ oas_mds_password_file: "{{ stage }}/oas_mds_password.txt" oas_biplatform_password_file: "{{ stage }}/oas_biplatform_password.txt" weblogic_password_file: "{{ stage }}/weblogic_password.txt" admin_password_file: "{{ stage }}/weblogic_password.txt" +admin_port: 7001 bip_repository_file: bip_repository_12Oct2023.tar weblogic_admin_username: weblogic +admin_server: AdminServer managed_server: bi_server1 scripts_dir: /home/oracle/admin/scripts weblogic_servers: diff --git a/ansible/roles/oasys-bip/tasks/clone_bip_software.yml b/ansible/roles/oasys-bip/tasks/clone_bip_software.yml index 0bfa30196..a20cf00e8 100644 --- a/ansible/roles/oasys-bip/tasks/clone_bip_software.yml +++ b/ansible/roles/oasys-bip/tasks/clone_bip_software.yml @@ -216,7 +216,7 @@ collected_files.files }} - - name: Pause for 15 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins + - name: Pause for 15 minutes. Sometimes the cloning can go wrong without a delay. Not sure why. ansible.builtin.pause: minutes: 15 @@ -238,18 +238,26 @@ poll: 30 when: not ansible_check_mode - - name: Boot.properties file creation for bi_server1 + - name: Boot.properties file creation for managed server ansible.builtin.copy: - src: "{{ domain_home }}/{{ domain_name }}/servers/AdminServer/security/boot.properties" - dest: "{{ domain_home }}/{{ domain_name }}/servers/bi_server1/security/boot.properties" + src: "{{ domain_home }}/{{ domain_name }}/servers/{{ admin_server }}/security/boot.properties" + dest: "{{ domain_home }}/{{ domain_name }}/servers/{{ managed_server }}/security/boot.properties" owner: oracle group: oinstall mode: "0600" remote_src: true - - name: Pause for 15 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins + - name: Fix startManagedWebLogic.sh + ansible.builtin.template: + src: "startManagedWebLogic.sh.j2" + dest: "{{domain_home}}/{{domain_name}}/bin/startManagedWebLogic.sh" + owner: oracle + group: oinstall + mode: "0750" + + - name: Pause for 1 minute. Not sure why. ansible.builtin.pause: - minutes: 15 + minutes: 1 - name: Enable Standalone BI Publisher to Add Privileges for Application Roles become_user: oracle diff --git a/ansible/roles/oasys-bip/tasks/install-jdk.yml b/ansible/roles/oasys-bip/tasks/install-jdk.yml index 6a819893e..a49e8d964 100644 --- a/ansible/roles/oasys-bip/tasks/install-jdk.yml +++ b/ansible/roles/oasys-bip/tasks/install-jdk.yml @@ -22,7 +22,7 @@ mode: get overwrite: latest loop: - - /u01/software/jdk/jdk-7u80-linux-x64.rpm + - /jdk/jdk-7u80-linux-x64.rpm when: image_builder_s3_bucket_name is defined - name: Install jdk rpm binary diff --git a/ansible/roles/oasys-bip/tasks/main.yml b/ansible/roles/oasys-bip/tasks/main.yml index e4cefb8e9..e1ba9f7e4 100644 --- a/ansible/roles/oasys-bip/tasks/main.yml +++ b/ansible/roles/oasys-bip/tasks/main.yml @@ -86,3 +86,8 @@ tags: - bip_db_create - never + +- import_tasks: service_managedserver.yml + tags: + - amibuild + - ec2provision diff --git a/ansible/roles/oasys-bip/tasks/service_managedserver.yml b/ansible/roles/oasys-bip/tasks/service_managedserver.yml new file mode 100644 index 000000000..c96e9f712 --- /dev/null +++ b/ansible/roles/oasys-bip/tasks/service_managedserver.yml @@ -0,0 +1,10 @@ +- name: Pause for 30 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins + ansible.builtin.pause: + minutes: 20 + +- name: Start weblogic managed server + ansible.builtin.service: + name: "{{ item }}" + state: started + loop: + - wls_managedserver diff --git a/ansible/roles/oasys-bip/tasks/services.yml b/ansible/roles/oasys-bip/tasks/services.yml index a62d27f27..a96f795fd 100644 --- a/ansible/roles/oasys-bip/tasks/services.yml +++ b/ansible/roles/oasys-bip/tasks/services.yml @@ -1,4 +1,7 @@ --- +- name: Reload necessary links and cache to the most recent shared libraries + ansible.builtin.shell: ldconfig + - name: Stop Weblogic and nodemanager become_user: oracle ansible.builtin.shell: | @@ -19,7 +22,7 @@ group: oinstall mode: "0700" -- name: Copy nodemanager systemd helper scripts +- name: Copy weblogic systemd helper scripts ansible.builtin.template: src: "10.3{{ item }}" dest: "{{ item }}" @@ -68,18 +71,18 @@ loop: - wls_nodemanager - wls_adminserver +# - name: Pause for 30 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins +# ansible.builtin.pause: +# minutes: 30 -- name: Pause for 15 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins - ansible.builtin.pause: - minutes: 15 - -- name: Start weblogic services - ansible.builtin.service: - name: "{{ item }}" - state: started - loop: - - wls_managedserver +# - name: Start weblogic managed server +# become: yes +# ansible.builtin.service: +# name: "{{ item }}" +# state: started +# loop: +# - wls_managedserver -- name: Pause for 15 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins - ansible.builtin.pause: - minutes: 15 +# - name: Pause for 15 minutes to let admin server start properly in few cases even though it was running connecting to it was causing issues for few mins +# ansible.builtin.pause: +# minutes: 15 diff --git a/ansible/roles/oasys-bip/tasks/setup-log-rotate.yml b/ansible/roles/oasys-bip/tasks/setup-log-rotate.yml index 5f735a7b5..fb41750a7 100644 --- a/ansible/roles/oasys-bip/tasks/setup-log-rotate.yml +++ b/ansible/roles/oasys-bip/tasks/setup-log-rotate.yml @@ -3,15 +3,6 @@ set_fact: weblogic_managed_app: "{{ weblogic_managed_app_list.name }}" -- name: Start services if not already running - ansible.builtin.service: - name: "{{ item }}" - state: started - loop: - - wls_nodemanager - - wls_adminserver - - wls_managedserver - - block: - name: Copy log setup managed app configuration files ansible.builtin.template: diff --git a/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_adminserver.service b/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_adminserver.service index 1c2bd2ea1..b8c1174d7 100644 --- a/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_adminserver.service +++ b/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_adminserver.service @@ -1,9 +1,9 @@ [Unit] Description=WebLogic Admin Server +After=wls_nodemanager.service [Service] Type=simple -After=wls_nodemanager TimeoutStartSec=300 ExecStart={{ scripts_dir }}/startWebLogic.sh ExecStartPost={{ scripts_dir }}/waitWebLogic.sh diff --git a/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_managedserver.service b/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_managedserver.service index 94d84ec2b..d12e2ffce 100644 --- a/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_managedserver.service +++ b/ansible/roles/oasys-bip/templates/10.3/etc/systemd/system/wls_managedserver.service @@ -1,9 +1,9 @@ [Unit] Description=WebLogic managed server Service +After=wls_adminserver.service [Service] Type=simple -After=wls_adminserver TimeoutStartSec=300 ExecStart={{ scripts_dir }}/startManagedWebLogic.sh ExecStartPost={{ scripts_dir }}/waitManagedWebLogic.sh diff --git a/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/set_ms_log_rotation.py b/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/set_ms_log_rotation.py index 49a3df0a7..4e904cfac 100644 --- a/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/set_ms_log_rotation.py +++ b/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/set_ms_log_rotation.py @@ -33,7 +33,7 @@ adminURL = configProps.get("admin.url") msName = configProps.get("ms.name") -# Connect to the AdminServer. +# Connect to the {{ admin_server }}. connect(adminUsername, adminPassword, adminURL) edit() diff --git a/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/weblogic.properties b/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/weblogic.properties index 0beca34a8..d831dd35e 100644 --- a/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/weblogic.properties +++ b/ansible/roles/oasys-bip/templates/10.3/home/oracle/admin/scripts/weblogic.properties @@ -1,2 +1,2 @@ -domain.adminServerName=AdminServer -domain.adminurl={{ weblogic_domain_hostname }}:7001 +domain.adminServerName={{ admin_server }} +domain.adminurl={{ weblogic_domain_hostname }}:{{ admin_port }} diff --git a/ansible/roles/oasys-bip/templates/AdminServer.properties b/ansible/roles/oasys-bip/templates/AdminServer.properties index 9976e6d1f..5eeee6a26 100644 --- a/ansible/roles/oasys-bip/templates/AdminServer.properties +++ b/ansible/roles/oasys-bip/templates/AdminServer.properties @@ -1,7 +1,7 @@ # AdminServer connection details. admin.username={{ weblogic_admin_username }} admin.password={{ weblogic_admin_password }} -admin.url={{ weblogic_domain_hostname }}:7001 +admin.url={{ weblogic_domain_hostname }}:{{ admin_port }} # Managed Server -ms.name=AdminServer \ No newline at end of file +ms.name={{ admin_server }} \ No newline at end of file diff --git a/ansible/roles/oasys-bip/templates/addApplicationPrivileges.exp.j2 b/ansible/roles/oasys-bip/templates/addApplicationPrivileges.exp.j2 index 8cdc180b2..3e42407da 100644 --- a/ansible/roles/oasys-bip/templates/addApplicationPrivileges.exp.j2 +++ b/ansible/roles/oasys-bip/templates/addApplicationPrivileges.exp.j2 @@ -1,7 +1,7 @@ #!/usr/bin/expect set PASSWORD [lindex $argv 0] -spawn {{ middleware_home }}/oracle_common/common/bin/wlst.sh {{ stage }}/addBIPCodeGrants.py t3://{{ weblogic_servername }}:7001 weblogic +spawn {{ middleware_home }}/oracle_common/common/bin/wlst.sh {{ stage }}/addBIPCodeGrants.py t3://{{ weblogic_servername }}:{{ admin_port }} weblogic expect "\Please enter password:\]" send "$PASSWORD\r" expect eof \ No newline at end of file diff --git a/ansible/roles/oasys-bip/templates/bi_config_moveplan.xml b/ansible/roles/oasys-bip/templates/bi_config_moveplan.xml index 15d839fea..eb8e55607 100644 --- a/ansible/roles/oasys-bip/templates/bi_config_moveplan.xml +++ b/ansible/roles/oasys-bip/templates/bi_config_moveplan.xml @@ -33,7 +33,7 @@ Server Name - AdminServer + {{ admin_server }} STRING READ_ONLY @@ -49,7 +49,7 @@ Listen Port - 7001 + {{ admin_port }} INTEGER READ_WRITE @@ -59,7 +59,7 @@ Server Name - bi_server1 + {{ managed_server }} STRING READ_ONLY @@ -157,7 +157,7 @@ Multicast Port - 7001 + {{ admin_port }} INTEGER READ_WRITE diff --git a/ansible/roles/oasys-bip/templates/bi_server1.properties b/ansible/roles/oasys-bip/templates/bi_server1.properties index f800abb72..e9e5c6716 100644 --- a/ansible/roles/oasys-bip/templates/bi_server1.properties +++ b/ansible/roles/oasys-bip/templates/bi_server1.properties @@ -1,8 +1,8 @@ -# AdminServer Connection +# {{ admin_server }} Connection admin.username={{ weblogic_admin_username }} admin.password={{ weblogic_admin_password }} -admin.url={{ weblogic_domain_hostname }}:7001 +admin.url={{ weblogic_domain_hostname }}:{{ admin_port }} # Managed Server -ms.name=bi_server1 +ms.name={{ managed_server }} diff --git a/ansible/roles/oasys-bip/templates/domain.properties b/ansible/roles/oasys-bip/templates/domain.properties index 45d64e651..c98a6852e 100644 --- a/ansible/roles/oasys-bip/templates/domain.properties +++ b/ansible/roles/oasys-bip/templates/domain.properties @@ -6,8 +6,8 @@ path.domain.config={{ domain_home }} # Credentials admin.username={{ weblogic_admin_username }} admin.password={{ weblogic_admin_password }} -admin.url={{ weblogic_domain_hostname }}:7001 -admin.port=7001 +admin.url={{ weblogic_domain_hostname }}:{{ admin_port }} +admin.port={{ admin_port }} admin.address={{ weblogic_domain_hostname }} # Domain details diff --git a/ansible/roles/oasys-bip/templates/nm_moveplan.xml b/ansible/roles/oasys-bip/templates/nm_moveplan.xml index 5b3a8f671..2615d22cf 100644 --- a/ansible/roles/oasys-bip/templates/nm_moveplan.xml +++ b/ansible/roles/oasys-bip/templates/nm_moveplan.xml @@ -59,7 +59,7 @@ - AdminServer Listen Address + {{ admin_server }} Listen Address {{ weblogic_domain_hostname }} STRING @@ -67,15 +67,15 @@ - AdminServer Listen Port - 7001 + {{ admin_server }} Listen Port + {{ admin_port }} INTEGER READ_WRITE - AdminServer User Name + {{ admin_server }} User Name weblogic STRING @@ -83,7 +83,7 @@ - AdminServer Password File + {{ admin_server }} Password File {{ weblogic_password_file }} STRING @@ -94,7 +94,7 @@ Custom Trust Keystore File - Provide the value of Custom Trust KeyStore File of the domain, if value of the config property "AdminServer Listen Port" mentioned above represents SSL port of the server. + Provide the value of Custom Trust KeyStore File of the domain, if value of the config property "{{ admin_server }} Listen Port" mentioned above represents SSL port of the server. STRING READ_WRITE diff --git a/ansible/roles/oasys-bip/templates/startManagedWebLogic.sh.j2 b/ansible/roles/oasys-bip/templates/startManagedWebLogic.sh.j2 new file mode 100644 index 000000000..bf1808f94 --- /dev/null +++ b/ansible/roles/oasys-bip/templates/startManagedWebLogic.sh.j2 @@ -0,0 +1,108 @@ + +#!/bin/sh + +# WARNING: This file is created by the Configuration Wizard. +# Any changes to this script may be lost when adding extensions to this configuration. +# ... and then replaced by ansible in https://github.com/ministryofjustice/modernisation-platform-configuration-management.git + +# --- Start Functions --- + +usage() +{ + echo "Need to set SERVER_NAME and ADMIN_URL environment variables or specify" + echo "them in command line:" + echo "Usage: $1 SERVER_NAME {ADMIN_URL}" + echo "for example:" + echo "$1 managedserver1 http://t1-oasys-bip-b.oasys.hmpps-test.modernisation-platform.internal:7001" +} + +# --- End Functions --- + +# ************************************************************************* +# This script is used to start a managed WebLogic Server for the domain in +# the current working directory. This script can either read in the SERVER_NAME and +# ADMIN_URL as positional parameters or will read them from environment variables that are +# set before calling this script. If SERVER_NAME is not sent as a parameter or exists with a value +# as an environment variable the script will EXIT. If the ADMIN_URL value cannot be determined +# by reading a parameter or from the environment a default value will be used. +# +# For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server" +# (http://download.oracle.com/docs/cd/E23943_01/web.1111/e13708/overview.htm) +# ************************************************************************* + +# Set SERVER_NAME to the name of the server you wish to start up. + +DOMAIN_NAME="{{ domain_name }}" + +ADMIN_URL="http://$(hostname --fqdn):{{ admin_port }}" + +# Set WLS_USER equal to your system username and WLS_PW equal + +# to your system password for no username and password prompt + +# during server startup. Both are required to bypass the startup + +# prompt. + +WLS_USER="" +export WLS_USER + +WLS_PW="" +export WLS_PW + +# Set JAVA_OPTIONS to the java flags you want to pass to the vm. i.e.: + +# set JAVA_OPTIONS=-Dweblogic.attribute=value -Djava.attribute=value + +JAVA_OPTIONS="-Dweblogic.security.SSL.trustedCAKeyStore=\"{{ wl_home }}/server/lib/cacerts\" ${JAVA_OPTIONS}" +export JAVA_OPTIONS + +# Set JAVA_VM to the java virtual machine you want to run. For instance: + +# set JAVA_VM=-server + +JAVA_VM="" + +# Set SERVER_NAME and ADMIN_URL, they must by specified before starting + +# a managed server, detailed information can be found at + +# http://download.oracle.com/docs/cd/E23943_01/web.1111/e13708/overview.htm + +if [ "$1" = "" ] ; then + if [ "${SERVER_NAME}" = "" ] ; then + usage $0 + exit + fi +else + SERVER_NAME="$1" + shift +fi + +if [ "$1" = "" ] ; then + if [ "${ADMIN_URL}" = "" ] ; then + usage $0 + exit + fi +else + ADMIN_URL="$1" + shift +fi + +# Export the admin_url whether the user specified it OR it was sent on the command-line + +ADMIN_URL="${ADMIN_URL}" +export ADMIN_URL + +SERVER_NAME="${SERVER_NAME}" +export SERVER_NAME + +DOMAIN_HOME="{{ domain_home }}/{{ domain_name }}" + +if [ "$1" = "" ] ; then + # Call Weblogic Server with our default params since the user did not specify any other ones + ${DOMAIN_HOME}/bin/startWebLogic.sh nodebug noderby noiterativedev notestconsole noLogErrorsToConsole +else + # Call Weblogic Server with the params the user sent in INSTEAD of the defaults + ${DOMAIN_HOME}/bin/startWebLogic.sh $1 $2 $3 $4 $5 $6 $7 $8 $9 +fi \ No newline at end of file