diff --git a/pom.xml b/pom.xml index 2b96f61..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 @@ -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": { diff --git a/src/main/scripts/was-check.sh b/src/main/scripts/was-check.sh new file mode 100644 index 0000000..52dd577 --- /dev/null +++ b/src/main/scripts/was-check.sh @@ -0,0 +1,98 @@ +#!/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. + +LOG_FILE=/tmp/deployment.log + +# Remove musl libc as IBM Java binaries only run on glibc +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 +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" \ + && 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) +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 +WAS_ND_VERSION_ENTITLED=ND.v90_9.0.5007 +NO_PACKAGES_FOUND="No packages were found" + +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} + +# Install IBM Installation Manager +wget -O ${IM_INSTALL_KIT} ${IM_INSTALL_KIT_URL} -q +unzip -q ${IM_INSTALL_KIT} -d ${IM_INSTALL_KIT_UNPACK} +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 +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 + 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" >> ${LOG_FILE} +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" >&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" >&2 + fi +fi + +# Remove temporary files +rm -rf storage_file && rm -rf im_install_log + +echo "$(date): Entitlement check completed." >> ${LOG_FILE} +if [ $result -eq 1 ]; then + exit 1 +fi