From 5ce05b57f8d26e624ad503656e22e242c8eaccc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de> Date: Tue, 23 Apr 2024 14:19:09 +0200 Subject: [PATCH] fix: make creation of global.properties more robust after SC07113708 --- .../ansible/facts.d/rosetta_app_version.fact | 46 ++++++++++++++++++- .../configure_rosetta_prerequisites.yml | 23 +++++++++- tasks/rosetta/main_rosetta.yml | 2 +- .../system.dir/conf/global.properties_http | 10 ++-- .../system.dir/conf/global.properties_https | 10 ++-- 5 files changed, 76 insertions(+), 15 deletions(-) diff --git a/files/etc/ansible/facts.d/rosetta_app_version.fact b/files/etc/ansible/facts.d/rosetta_app_version.fact index f0fafde..f416b46 100644 --- a/files/etc/ansible/facts.d/rosetta_app_version.fact +++ b/files/etc/ansible/facts.d/rosetta_app_version.fact @@ -1,8 +1,50 @@ #!/usr/bin/env bash +# We assume that the global.properties file is either created by the Rosetta +# updater and thus contains the correct version string or is created by our +# Ansible tasks that derive the version from a Rosetta config and should there- +# fore also contain the valid version string. +# As things happen, this assumption might not always be true, so we back this +# information with the latest version stored in the Oracle database. +# Whenever the versions differ, this script fails. + + + +### Extract version string from global.properties config file. # example string in global.properties file: # app.version=8.1.0.0 if [[ -e "/exlibris/dps/d4_1/system.dir/conf/global.properties" ]]; then - ver=$( grep -r "app.version" /exlibris/dps/d4_1/system.dir/conf/global.properties | cut -d "=" -f2 ); - echo "{\"version\" : \"${ver}\"}"; + confver=$( grep -r "app.version" /exlibris/dps/d4_1/system.dir/conf/global.properties | cut -d "=" -f2 ); +fi + + + +### Extract version string from Oracle database. +# Copy-pasta from $dps_dev/system.dir/bin/dps_info.csh lines 212 following +# slightly modified to show only latest version +# ------------------------ BEGIN get rosetta details +dbver=$( sqlplus -s << ! +${ORA_USER_PREFIX}SHR00/`get_ora_passwd ${ORA_USER_PREFIX}SHR00` + +set pause off +set pagesize 1000 +set newpage none +set linesize 2048 +set heading off +set feedback off +set trimspool on +SELECT version FROM application_version ORDER BY ID DESC FETCH FIRST 1 ROWS ONLY; +! +) +# ------------------------ END get rosetta details + + + +### Compare obtained version strings and return result to be used in Ansible +### facts. +if [[ "${confver}" != "${dbver}" ]]; then + echo "ERROR! The global.properties config file is showing a different version from the one stored in the Oracle database. Please rectify the situation and try again. Config-Version: '${confver}', DB-Version: '${dbver}'." + exit 1 +else + echo "{\"version\" : \"${dbver}\"}"; fi diff --git a/tasks/rosetta/configure_rosetta_prerequisites.yml b/tasks/rosetta/configure_rosetta_prerequisites.yml index d83bb54..5a5c9b3 100644 --- a/tasks/rosetta/configure_rosetta_prerequisites.yml +++ b/tasks/rosetta/configure_rosetta_prerequisites.yml @@ -4,6 +4,17 @@ path: "/exlibris/dps/d4_1/system.dir/conf/global.properties" register: stat +- name: > + create backup of global.properties file is it is not already a symlink + (meaning it hasn't been replaced by the Ansible tasks yet) + ansible.builtin.copy: + src: "/exlibris/dps/d4_1/system.dir/conf/global.properties" + dest: "/exlibris/dps/d4_1/system.dir/conf/global.properties_ANSIBLE_BAK_{{ ansible_date_time.iso8601 }}" + remote_src: true + when: stat.stat.isreg is true + + + - name: template global.properties PROD ansible.builtin.template: src: "{{ item }}" @@ -24,8 +35,8 @@ loop: - "exlibris/dps/d4_1/system.dir/conf/global.properties_http" - "exlibris/dps/d4_1/system.dir/conf/global.properties_https" -# when: ("appprod0" in ansible_hostname) - when: false + when: ("appprod0" in ansible_hostname) + changed_when: false - name: set symlink for correct global.properties PROD ansible.builtin.file: src: "/exlibris/dps/d4_1/system.dir/conf/global.properties_http" @@ -34,6 +45,8 @@ # when: ("appprod0" in ansible_hostname) when: false + + - name: template global.properties TEST ansible.builtin.template: src: "{{ item }}" @@ -55,6 +68,7 @@ - "exlibris/dps/d4_1/system.dir/conf/global.properties_http" - "exlibris/dps/d4_1/system.dir/conf/global.properties_https" when: ("-test" in ansible_hostname) + changed_when: false - name: set symlink for correct global.properties TEST ansible.builtin.file: src: "/exlibris/dps/d4_1/system.dir/conf/global.properties_https" @@ -65,6 +79,8 @@ - ( "-test" in ansible_hostname ) - ( stat.stat.isreg is true ) + + - name: template global.properties DEV ansible.builtin.template: src: "{{ item }}" @@ -86,6 +102,7 @@ - "exlibris/dps/d4_1/system.dir/conf/global.properties_http" - "exlibris/dps/d4_1/system.dir/conf/global.properties_https" when: ("appdev" in ansible_hostname) + changed_when: false - name: set symlink for correct global.properties DEV ansible.builtin.file: @@ -97,6 +114,8 @@ - ( "appdev" in ansible_hostname ) - ( stat.stat.isreg is true ) + + - name: create directory for Solr config file ansible.builtin.file: path: "/exlibris/dps/d4_1/solr/server/solr/" diff --git a/tasks/rosetta/main_rosetta.yml b/tasks/rosetta/main_rosetta.yml index 1b8bce0..50db7db 100644 --- a/tasks/rosetta/main_rosetta.yml +++ b/tasks/rosetta/main_rosetta.yml @@ -12,7 +12,7 @@ tags: [iptables] - name: configure Rosetta prerequisites ansible.builtin.import_tasks: "rosetta/configure_rosetta_prerequisites.yml" - tags: [rosetta] + tags: [rosetta, globalproperties, solr] - name: configure Rosetta maintenance timer ansible.builtin.import_tasks: "rosetta/configure_maintenance.yml" tags: [rosetta, maintenance, systemd, timer, cron, cronjob] diff --git a/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_http b/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_http index 5ae73b8..2d1aefd 100644 --- a/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_http +++ b/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_http @@ -13,8 +13,8 @@ dbconnection.rpt.username=V2SL_rpt00 dbconnection.shr.username=V2SL_shr00 dbconnection.url=jdbc\:oracle\:thin\:@{{ dbconnection_url }}\:1521\:{{ ora_sid }} debug.port=5001 -del.server={{ ansible_hostname }} -dep.server={{ ansible_hostname }} +del.server={{ ansible_fqdn }} +dep.server={{ ansible_fqdn }} dps.dev=/exlibris/dps/d4_1 dps.nfs.shared.all=/operational_shared/ dps.nfs.storage.dep=/deposit_storage @@ -25,7 +25,7 @@ droid.maxmemory=512m http.connectiontimeout=20000 http.port={{ http_port }} https.port=443 -idx.server={{ ansible_hostname }} +idx.server={{ ansible_fqdn }} image.magick.lib=/exlibris/dps/d4_1/product/local/im/lib java.home=/exlibris/dps/d4_1/product/local/java jboss.java.opts=-XX\:+HeapDumpOnOutOfMemoryError -XX\:HeapDumpPath\=$dps_dev/system.dir/thirdparty/jboss/server/default/log/ -Xloggc\:$dps_dev/system.dir/thirdparty/jboss/server/default/log/gc.log -XX\:+PrintTenuringDistribution -XX\:+PrintGCDetails -XX\:+PrintGCTimeStamps -XX\:+PrintGCDateStamps -Dfile.encoding\=utf8 -XX\:+UseConcMarkSweepGC -XX\:+CMSIncrementalMode @@ -67,11 +67,11 @@ protocol.idx=http protocol.pds=http protocol.per=http protocol.rep=http -rep.server={{ ansible_hostname }} +rep.server={{ ansible_fqdn }} rmi.object.port=3901 rmi.port=3801 server.ip={{ ansible_default_ipv4.address }} -server.name={{ ansible_hostname }} +server.name={{ ansible_fqdn }} server.pool.port=6801 solr.maxmemory=4000 solr.minmemory=256 diff --git a/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_https b/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_https index 65e92cc..413190c 100644 --- a/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_https +++ b/templates/exlibris/dps/d4_1/system.dir/conf/global.properties_https @@ -13,8 +13,8 @@ dbconnection.rpt.username=V2SL_rpt00 dbconnection.shr.username=V2SL_shr00 dbconnection.url=jdbc\:oracle\:thin\:@{{ dbconnection_url }}\:1521\:{{ ora_sid }} debug.port=5001 -del.server={{ ansible_hostname }} -dep.server={{ ansible_hostname }} +del.server={{ ansible_fqdn }} +dep.server={{ ansible_fqdn }} dps.dev=/exlibris/dps/d4_1 dps.nfs.shared.all=/operational_shared/ dps.nfs.storage.dep=/deposit_storage @@ -25,7 +25,7 @@ droid.maxmemory=512m http.connectiontimeout=20000 http.port={{ http_port }} https.port=443 -idx.server={{ ansible_hostname }} +idx.server={{ ansible_fqdn }} image.magick.lib=/exlibris/dps/d4_1/product/local/im/lib java.home=/exlibris/dps/d4_1/product/local/java jboss.java.opts=-XX\:+HeapDumpOnOutOfMemoryError -XX\:HeapDumpPath\=$dps_dev/system.dir/thirdparty/jboss/server/default/log/ -Xloggc\:$dps_dev/system.dir/thirdparty/jboss/server/default/log/gc.log -XX\:+PrintTenuringDistribution -XX\:+PrintGCDetails -XX\:+PrintGCTimeStamps -XX\:+PrintGCDateStamps -Dfile.encoding\=utf8 -XX\:+UseConcMarkSweepGC -XX\:+CMSIncrementalMode @@ -67,11 +67,11 @@ protocol.idx=http protocol.pds=http protocol.per=https protocol.rep=https -rep.server={{ ansible_hostname }} +rep.server={{ ansible_fqdn }} rmi.object.port=3901 rmi.port=3801 server.ip={{ ansible_default_ipv4.address }} -server.name={{ ansible_hostname }} +server.name={{ ansible_fqdn }} server.pool.port=6801 solr.maxmemory=4000 solr.minmemory=256 -- GitLab