From c03cc24ec47df137a0468d26892f3d76958114c5 Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Fri, 24 Sep 2021 14:26:58 +0800 Subject: [PATCH 1/7] deploymentScript for checking entitlement Signed-off-by: Jianguo Ma --- src/main/scripts/was-check.sh | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/scripts/was-check.sh diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh new file mode 100644 index 0000000..9c00793 --- /dev/null +++ b/src/main/scripts/was-check.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Copyright (c) Microsoft Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Define const variables for IM installation +WAS_ND_VERSION_ENTITLED=ND.v90_9.0.5007 +NO_PACKAGES_FOUND="No packages were found" +IM_INSTALL_KIT=agent.installer.linux.gtk.x86_64.zip +IM_INSTALL_KIT_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/im/zips/${IM_INSTALL_KIT} +IM_INSTALL_DIRECTORY=IBM/InstallationManager/V1.9 +logFile=deployment.log + +echo "$(date): Start to install IBM Installation Manager." > $logFile + +# Create installation directories +mkdir -p ${IM_INSTALL_DIRECTORY} + +# Install IBM Installation Manager +wget -O "$IM_INSTALL_KIT" "$IM_INSTALL_KIT_URL" -q +mkdir im_installer +unzip -q "$IM_INSTALL_KIT" -d im_installer +./im_installer/userinstc -log log_file -acceptLicense -installationDirectory ${IM_INSTALL_DIRECTORY} + +echo "$(date): IBM Installation Manager installed, start to check entitlement." >> $logFile + +# Save credentials to a secure storage file +${IM_INSTALL_DIRECTORY}/eclipse/tools/imutilsc saveCredential -secureStorageFile storage_file \ + -userName "$IBM_USER_ID" -userPassword "$IBM_USER_PWD" -passportAdvantage + +# Check whether IBMid is entitled or not +if [ $? -ne 0 ]; then + echo "Cannot connect to Passport Advantage while saving the credential to the secure storage file." >> $logFile +fi + +result=0 +output=$(${IM_INSTALL_DIRECTORY}/eclipse/tools/imcl listAvailablePackages -cPA -secureStorageFile storage_file) +if [ echo $output | grep -q "$WAS_ND_VERSION_ENTITLED" ]; then + echo "Entitled" >> $logFile +else + result=1 + if [ echo $output | grep -q "$NO_PACKAGES_FOUND" ]; then + echo "Undefined" >> $logFile + echo "No WebSphere Application Server installation packages were found. This is likely due to a temporary issue with the installation repository. Try again and open an IBM Support issue if the problem persists." + else + echo "Unentitled" >> $logFile + echo "The provided IBM ID does not have entitlement to install WebSphere Application Server. Please contact the primary or secondary contacts for your IBM Passport Advantage site to grant you access or follow steps at IBM eCustomer Care (https://ibm.biz/IBMidEntitlement) for further assistance." + fi +fi + +# Remove temporary files +rm -rf storage_file && rm -rf log_file + +echo "$(date): Entitlement check completed." >> $logFile +[ $result -eq 1 ] && exit 1 From 02409444fb75e107d1d676c1906b29f39522f83e Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Fri, 24 Sep 2021 14:45:37 +0800 Subject: [PATCH 2/7] use /tmp as working directory Signed-off-by: Jianguo Ma --- src/main/scripts/was-check.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh index 9c00793..5a14455 100644 --- a/src/main/scripts/was-check.sh +++ b/src/main/scripts/was-check.sh @@ -19,9 +19,10 @@ WAS_ND_VERSION_ENTITLED=ND.v90_9.0.5007 NO_PACKAGES_FOUND="No packages were found" IM_INSTALL_KIT=agent.installer.linux.gtk.x86_64.zip IM_INSTALL_KIT_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/im/zips/${IM_INSTALL_KIT} -IM_INSTALL_DIRECTORY=IBM/InstallationManager/V1.9 -logFile=deployment.log +IM_INSTALL_DIRECTORY=/tmp/IBM/InstallationManager/V1.9 +logFile=/tmp/deployment.log +cd /tmp echo "$(date): Start to install IBM Installation Manager." > $logFile # Create installation directories From d20945a450f52cf9946757ac4f545919d754a42f Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Sun, 26 Sep 2021 13:24:32 +0800 Subject: [PATCH 3/7] replace musl libc with glibc Signed-off-by: Jianguo Ma --- src/main/scripts/was-check.sh | 64 +++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh index 5a14455..eb92d78 100644 --- a/src/main/scripts/was-check.sh +++ b/src/main/scripts/was-check.sh @@ -14,27 +14,49 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Remove musl libc as IBM Java binaries only run on glibc +apk del libc6-compat + +# Install glibc by referencing to https://github.com/ibmruntimes/ci.docker/blob/master/ibmjava/8/jre/alpine/Dockerfile +apk add --no-cache --virtual .build-deps curl binutils \ + && GLIBC_VER="2.30-r0" \ + && ALPINE_GLIBC_REPO="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" \ + && GCC_LIBS_URL="https://archive.archlinux.org/packages/g/gcc-libs/gcc-libs-8.2.1%2B20180831-1-x86_64.pkg.tar.xz" \ + && GCC_LIBS_SHA256=e4b39fb1f5957c5aab5c2ce0c46e03d30426f3b94b9992b009d417ff2d56af4d \ + && curl -fLs https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /tmp/sgerrand.rsa.pub \ + && cp /tmp/sgerrand.rsa.pub /etc/apk/keys \ + && curl -fLs ${ALPINE_GLIBC_REPO}/${GLIBC_VER}/glibc-${GLIBC_VER}.apk > /tmp/${GLIBC_VER}.apk \ + && apk add /tmp/${GLIBC_VER}.apk \ + && curl -fLs ${GCC_LIBS_URL} -o /tmp/gcc-libs.tar.xz \ + && echo "${GCC_LIBS_SHA256} /tmp/gcc-libs.tar.xz" | sha256sum -c - \ + && mkdir /tmp/gcc \ + && tar -xf /tmp/gcc-libs.tar.xz -C /tmp/gcc \ + && mv /tmp/gcc/usr/lib/libgcc* /tmp/gcc/usr/lib/libstdc++* /usr/glibc-compat/lib \ + && strip /usr/glibc-compat/lib/libgcc_s.so.* /usr/glibc-compat/lib/libstdc++.so* \ + && apk del --purge .build-deps \ + && apk add --no-cache ca-certificates openssl \ + && rm -rf /tmp/${GLIBC_VER}.apk /tmp/gcc /tmp/gcc-libs.tar.xz /var/cache/apk/* /tmp/*.pub + # Define const variables for IM installation +IM_INSTALL_KIT_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/im/zips/agent.installer.linux.gtk.x86_64.zip +IM_INSTALL_KIT=/tmp/agent.installer.linux.gtk.x86_64.zip +IM_INSTALL_KIT_UNPACK=/tmp/im_installer +IM_INSTALL_DIRECTORY=/tmp/IBM/InstallationManager/V1.9 +LOG_FILE=/tmp/deployment.log WAS_ND_VERSION_ENTITLED=ND.v90_9.0.5007 NO_PACKAGES_FOUND="No packages were found" -IM_INSTALL_KIT=agent.installer.linux.gtk.x86_64.zip -IM_INSTALL_KIT_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/im/zips/${IM_INSTALL_KIT} -IM_INSTALL_DIRECTORY=/tmp/IBM/InstallationManager/V1.9 -logFile=/tmp/deployment.log -cd /tmp -echo "$(date): Start to install IBM Installation Manager." > $logFile +echo "$(date): Start to install IBM Installation Manager." > ${LOG_FILE} # Create installation directories -mkdir -p ${IM_INSTALL_DIRECTORY} +mkdir -p ${IM_INSTALL_KIT_UNPACK} && mkdir -p ${IM_INSTALL_DIRECTORY} # Install IBM Installation Manager -wget -O "$IM_INSTALL_KIT" "$IM_INSTALL_KIT_URL" -q -mkdir im_installer -unzip -q "$IM_INSTALL_KIT" -d im_installer -./im_installer/userinstc -log log_file -acceptLicense -installationDirectory ${IM_INSTALL_DIRECTORY} +wget -O ${IM_INSTALL_KIT} ${IM_INSTALL_KIT_URL} -q +unzip -q ${IM_INSTALL_KIT} -d ${IM_INSTALL_KIT_UNPACK} +${IM_INSTALL_KIT_UNPACK}/userinstc -log ${LOG_FILE} -acceptLicense -installationDirectory ${IM_INSTALL_DIRECTORY} -echo "$(date): IBM Installation Manager installed, start to check entitlement." >> $logFile +echo "$(date): IBM Installation Manager installed, start to check entitlement." >> ${LOG_FILE} # Save credentials to a secure storage file ${IM_INSTALL_DIRECTORY}/eclipse/tools/imutilsc saveCredential -secureStorageFile storage_file \ @@ -42,26 +64,26 @@ ${IM_INSTALL_DIRECTORY}/eclipse/tools/imutilsc saveCredential -secureStorageFile # Check whether IBMid is entitled or not if [ $? -ne 0 ]; then - echo "Cannot connect to Passport Advantage while saving the credential to the secure storage file." >> $logFile + echo "Cannot connect to Passport Advantage while saving the credential to the secure storage file." >> ${LOG_FILE} fi result=0 output=$(${IM_INSTALL_DIRECTORY}/eclipse/tools/imcl listAvailablePackages -cPA -secureStorageFile storage_file) -if [ echo $output | grep -q "$WAS_ND_VERSION_ENTITLED" ]; then - echo "Entitled" >> $logFile +if echo $output | grep -q "$WAS_ND_VERSION_ENTITLED"; then + echo "Entitled" >> ${LOG_FILE} else result=1 - if [ echo $output | grep -q "$NO_PACKAGES_FOUND" ]; then - echo "Undefined" >> $logFile + if echo $output | grep -q "$NO_PACKAGES_FOUND"; then + echo "Undefined" >> ${LOG_FILE} echo "No WebSphere Application Server installation packages were found. This is likely due to a temporary issue with the installation repository. Try again and open an IBM Support issue if the problem persists." else - echo "Unentitled" >> $logFile + echo "Unentitled" >> ${LOG_FILE} echo "The provided IBM ID does not have entitlement to install WebSphere Application Server. Please contact the primary or secondary contacts for your IBM Passport Advantage site to grant you access or follow steps at IBM eCustomer Care (https://ibm.biz/IBMidEntitlement) for further assistance." fi fi -# Remove temporary files -rm -rf storage_file && rm -rf log_file +# Remove the secure storage file +rm -rf storage_file -echo "$(date): Entitlement check completed." >> $logFile +echo "$(date): Entitlement check completed." >> ${LOG_FILE} [ $result -eq 1 ] && exit 1 From 39344521c094647496b9055d1210d06c82aa123b Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Sun, 26 Sep 2021 14:07:32 +0800 Subject: [PATCH 4/7] redirect log to deployment.log Signed-off-by: Jianguo Ma --- src/main/scripts/was-check.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh index eb92d78..4731f73 100644 --- a/src/main/scripts/was-check.sh +++ b/src/main/scripts/was-check.sh @@ -14,11 +14,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +LOG_FILE=/tmp/deployment.log + # Remove musl libc as IBM Java binaries only run on glibc -apk del libc6-compat +echo "$(date): Start to uninstall musl libc." > ${LOG_FILE} +output=$(apk del libc6-compat) +echo $output >> ${LOG_FILE} # Install glibc by referencing to https://github.com/ibmruntimes/ci.docker/blob/master/ibmjava/8/jre/alpine/Dockerfile -apk add --no-cache --virtual .build-deps curl binutils \ +echo "$(date): Musl libc uninstalled, start to install glibc." >> ${LOG_FILE} +output=$(apk add --no-cache --virtual .build-deps curl binutils \ && GLIBC_VER="2.30-r0" \ && ALPINE_GLIBC_REPO="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" \ && GCC_LIBS_URL="https://archive.archlinux.org/packages/g/gcc-libs/gcc-libs-8.2.1%2B20180831-1-x86_64.pkg.tar.xz" \ @@ -35,18 +40,18 @@ apk add --no-cache --virtual .build-deps curl binutils \ && strip /usr/glibc-compat/lib/libgcc_s.so.* /usr/glibc-compat/lib/libstdc++.so* \ && apk del --purge .build-deps \ && apk add --no-cache ca-certificates openssl \ - && rm -rf /tmp/${GLIBC_VER}.apk /tmp/gcc /tmp/gcc-libs.tar.xz /var/cache/apk/* /tmp/*.pub + && rm -rf /tmp/${GLIBC_VER}.apk /tmp/gcc /tmp/gcc-libs.tar.xz /var/cache/apk/* /tmp/*.pub) +echo $output >> ${LOG_FILE} # Define const variables for IM installation IM_INSTALL_KIT_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/im/zips/agent.installer.linux.gtk.x86_64.zip IM_INSTALL_KIT=/tmp/agent.installer.linux.gtk.x86_64.zip IM_INSTALL_KIT_UNPACK=/tmp/im_installer IM_INSTALL_DIRECTORY=/tmp/IBM/InstallationManager/V1.9 -LOG_FILE=/tmp/deployment.log WAS_ND_VERSION_ENTITLED=ND.v90_9.0.5007 NO_PACKAGES_FOUND="No packages were found" -echo "$(date): Start to install IBM Installation Manager." > ${LOG_FILE} +echo "$(date): Glibc installed, start to install IBM Installation Manager." >> ${LOG_FILE} # Create installation directories mkdir -p ${IM_INSTALL_KIT_UNPACK} && mkdir -p ${IM_INSTALL_DIRECTORY} @@ -54,13 +59,15 @@ mkdir -p ${IM_INSTALL_KIT_UNPACK} && mkdir -p ${IM_INSTALL_DIRECTORY} # Install IBM Installation Manager wget -O ${IM_INSTALL_KIT} ${IM_INSTALL_KIT_URL} -q unzip -q ${IM_INSTALL_KIT} -d ${IM_INSTALL_KIT_UNPACK} -${IM_INSTALL_KIT_UNPACK}/userinstc -log ${LOG_FILE} -acceptLicense -installationDirectory ${IM_INSTALL_DIRECTORY} +output=$(${IM_INSTALL_KIT_UNPACK}/userinstc -log im_install_log -acceptLicense -installationDirectory ${IM_INSTALL_DIRECTORY}) +echo $output >> ${LOG_FILE} echo "$(date): IBM Installation Manager installed, start to check entitlement." >> ${LOG_FILE} # Save credentials to a secure storage file -${IM_INSTALL_DIRECTORY}/eclipse/tools/imutilsc saveCredential -secureStorageFile storage_file \ - -userName "$IBM_USER_ID" -userPassword "$IBM_USER_PWD" -passportAdvantage +output=$(${IM_INSTALL_DIRECTORY}/eclipse/tools/imutilsc saveCredential -secureStorageFile storage_file \ + -userName "$IBM_USER_ID" -userPassword "$IBM_USER_PWD" -passportAdvantage) +echo $output >> ${LOG_FILE} # Check whether IBMid is entitled or not if [ $? -ne 0 ]; then @@ -82,8 +89,14 @@ else fi fi -# Remove the secure storage file -rm -rf storage_file +# Remove temporary files +rm -rf storage_file && rm -rf im_install_log echo "$(date): Entitlement check completed." >> ${LOG_FILE} + +# Output outputs +errInfo="Unentitled user" +outputJson=$(jq -n -c --arg errInfo $errInfo '{test: $errInfo}') +echo $outputJson > $AZ_SCRIPTS_OUTPUT_PATH + [ $result -eq 1 ] && exit 1 From 605aad0f8c8abbae22ca02272fdaaf2bf65ad275 Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Sun, 26 Sep 2021 14:36:57 +0800 Subject: [PATCH 5/7] output error info to stderr Signed-off-by: Jianguo Ma --- src/main/scripts/was-check.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh index 4731f73..52dd577 100644 --- a/src/main/scripts/was-check.sh +++ b/src/main/scripts/was-check.sh @@ -82,10 +82,10 @@ else result=1 if echo $output | grep -q "$NO_PACKAGES_FOUND"; then echo "Undefined" >> ${LOG_FILE} - echo "No WebSphere Application Server installation packages were found. This is likely due to a temporary issue with the installation repository. Try again and open an IBM Support issue if the problem persists." + echo "No WebSphere Application Server installation packages were found. This is likely due to a temporary issue with the installation repository. Try again and open an IBM Support issue if the problem persists" >&2 else echo "Unentitled" >> ${LOG_FILE} - echo "The provided IBM ID does not have entitlement to install WebSphere Application Server. Please contact the primary or secondary contacts for your IBM Passport Advantage site to grant you access or follow steps at IBM eCustomer Care (https://ibm.biz/IBMidEntitlement) for further assistance." + echo "The provided IBM ID does not have entitlement to install WebSphere Application Server. Please contact the primary or secondary contacts for your IBM Passport Advantage site to grant you access or follow steps at IBM eCustomer Care (https://ibm.biz/IBMidEntitlement) for further assistance" >&2 fi fi @@ -93,10 +93,6 @@ fi rm -rf storage_file && rm -rf im_install_log echo "$(date): Entitlement check completed." >> ${LOG_FILE} - -# Output outputs -errInfo="Unentitled user" -outputJson=$(jq -n -c --arg errInfo $errInfo '{test: $errInfo}') -echo $outputJson > $AZ_SCRIPTS_OUTPUT_PATH - -[ $result -eq 1 ] && exit 1 +if [ $result -eq 1 ]; then + exit 1 +fi From e2f3c99f04d082e457c6139a85c3605a69dfcf7c Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Sun, 26 Sep 2021 15:52:00 +0800 Subject: [PATCH 6/7] create a deploymentScript resource to do pre-entitlement check Signed-off-by: Jianguo Ma --- pom.xml | 1 + src/main/arm/mainTemplate.json | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pom.xml b/pom.xml index 2b96f61..c7e9fbc 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ -TestParameter '@{"PasswordMinLength"=6}' 2020-06-01 2019-06-01 + 2020-10-01 pid-fb16aee1-039d-45dc-a476-806224793a6c-partnercenter c2efe274-0dc2-50f3-b51f-338a3fe01afb 9c5dbfce-a6b9-5659-96bc-ca0cf429122a diff --git a/src/main/arm/mainTemplate.json b/src/main/arm/mainTemplate.json index f3fcc91..f6268f5 100644 --- a/src/main/arm/mainTemplate.json +++ b/src/main/arm/mainTemplate.json @@ -218,6 +218,8 @@ "name_share": "wasshare", "name_storageAccount": "[concat('storage',take(replace(parameters('guidValue'),'-',''),6))]", "name_virtualNetwork": "[concat(variables('const_dnsLabelPrefix'), '-vnet')]", + "name_deploymentScript": "[concat('script', take(replace(parameters('guidValue'), '-', ''), 6))]", + "ref_deploymentScript": "[resourceId('Microsoft.Resources/deploymentScripts', variables('name_deploymentScript'))]", "ref_fileService": "[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('name_storageAccount'), 'default')]", "ref_fileShare": "[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', variables('name_storageAccount'), 'default', variables('name_share'))]", "ref_ihsPublicIPAddress": "[resourceId('Microsoft.Network/publicIPAddresses', variables('name_ihsPublicIPAddress'))]", @@ -257,11 +259,37 @@ } } }, + { + "type": "Microsoft.Resources/deploymentScripts", + "apiVersion": "${azure.apiVersion.deploymentScript}", + "name": "[variables('name_deploymentScript')]", + "location": "[parameters('location')]", + "kind": "AzureCLI", + "properties": { + "AzCliVersion": "2.15.0", + "environmentVariables": [ + { + "name": "IBM_USER_ID", + "value": "[parameters('ibmUserId')]" + }, + { + "name": "IBM_USER_PWD", + "secureValue": "[parameters('ibmUserPwd')]" + } + ], + "primaryScriptUri": "[uri(variables('const_scriptLocation'), concat('was-check.sh', parameters('_artifactsLocationSasToken')))]", + "cleanupPreference": "OnSuccess", + "retentionInterval": "P1D" + } + }, { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "${azure.apiVersion2}", "name": "[variables('name_storageAccount')]", "location": "[parameters('location')]", + "dependsOn": [ + "[variables('ref_deploymentScript')]" + ], "sku": { "name": "Standard_LRS" }, @@ -298,6 +326,9 @@ "apiVersion": "${azure.apiVersion}", "name": "[variables('name_networkSecurityGroup')]", "location": "[parameters('location')]", + "dependsOn": [ + "[variables('ref_deploymentScript')]" + ], "properties": { "securityRules": [ { @@ -360,6 +391,9 @@ "apiVersion": "${azure.apiVersion}", "name": "[variables('name_publicIPAddress')]", "location": "[parameters('location')]", + "dependsOn": [ + "[variables('ref_deploymentScript')]" + ], "properties": { "publicIPAllocationMethod": "Dynamic", "dnsSettings": { @@ -574,6 +608,9 @@ "apiVersion": "${azure.apiVersion}", "name": "[variables('name_ihsPublicIPAddress')]", "location": "[parameters('location')]", + "dependsOn": [ + "[variables('ref_deploymentScript')]" + ], "properties": { "publicIPAllocationMethod": "Dynamic", "dnsSettings": { From 596786845639ccd035c2ffb02432d7703ef2db39 Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Sat, 9 Oct 2021 07:36:16 +0800 Subject: [PATCH 7/7] bump package version Signed-off-by: Jianguo Ma --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7e9fbc..28d261e 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.ibm.websphere.azure azure.websphere-traditional.cluster - 1.3.25 + 1.3.26 com.microsoft.azure.iaas