Skip to content

Commit

Permalink
Fix WLST py scripts. (#65)
Browse files Browse the repository at this point in the history
* Fix WLST py scripts.

	modified:   src/main/scripts/aadIntegration.sh
		Execute py script with oracle user
	modified:   src/main/scripts/datasourceConfig-oracle.sh
		Execute py script with oracle user
		Fix: datasource config fails silently
	modified:   src/main/scripts/datasourceConfig-postgresql.sh
		Fix: datasource config fails silently
		Execute py script with oracle user
	modified:   src/main/scripts/datasourceConfig-sqlserver.sh
		Execute py script with oracle user
		Fix: datasource config fails silently
	modified:   src/main/scripts/elkIntegration.sh
		Execute py script with oracle user

* Fix DB CI/CD parameters

* CI/CD failure on verifying Weblogic Server Access
  • Loading branch information
galiacheng committed Dec 10, 2020
1 parent 417cd13 commit 691f676
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 73 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

env:
azCliVersion: 2.6.0
adminConsolePort: 7005
dbName: wlsdb${{ github.run_id }}${{ github.run_number }}
elkURI: ${{ secrets.ELK_URI }}
elkUser: ${{ secrets.ELK_USER_NAME }}
Expand Down Expand Up @@ -152,11 +153,19 @@ jobs:
--name ${{ env.dbName }} \
--location ${location} \
--admin-user weblogic \
--ssl-enforcement Disabled \
--ssl-enforcement Enabled \
--public-network-access Enabled \
--admin-password ${{ env.wlsPassword }} \
--sku-name B_Gen5_1
echo "Allow Access To Azure Services"
az postgres server firewall-rule create \
-g ${{ env.resourceGroupForDependency }} \
-s ${{ env.dbName }} \
-n "AllowAllWindowsAzureIps" \
--start-ip-address "0.0.0.0" \
--end-ip-address "0.0.0.0"
deploy-weblogic-admin:
needs: deploy-dependencies
runs-on: ubuntu-latest
Expand Down Expand Up @@ -223,12 +232,7 @@ jobs:
s/#gitUserName#/$userName/g" \
${{ env.offerName }}/test/data/parameters-test.json
sed -i "s/#adminPasswordOrKey#/$wlsPassword/g" \
${{ env.offerName }}/test/scripts/verify-wls-path.sh
sed -i "s/#adminVMName#/$adminVMName/g; \
s/#adminPasswordOrKey#/$wlsPassword/g; \
s/#wlsUserName#/$wlsUserName/g; \
s/#wlspassword#/$wlsPassword/g" \
${{ env.offerName }}/test/scripts/verify-wls-access.sh
${{ env.offerName }}/test/scripts/verify-wls-path.sh
- name: Accept Image Terms
id: accept-terms
Expand Down Expand Up @@ -296,7 +300,7 @@ jobs:
--nsg-name ${nsg} \
--name NRMS-Rule-101 \
--source-address-prefixes $sourceAddressPrefixes \
--destination-port-ranges 443 22
--destination-port-ranges 443 22 ${adminConsolePort}
- name: Restart wls VM
id: restart-wls-wm
Expand Down Expand Up @@ -330,7 +334,18 @@ jobs:
echo "Verifying Weblgic server installation"
timeout 6m sh -c 'until nc -zv $0 $1; do echo "nc rc: $?"; sleep 5; done' ${wlsPublicIP} 22
sshpass -p ${wlsPassword} -v ssh -p 22 -o StrictHostKeyChecking=no -o ConnectTimeout=100 -v -tt weblogic@${wlsPublicIP} 'bash -s' < ${{ env.offerName }}/test/scripts/verify-wls-path.sh
- name: Restart remote SSH agent
id: restart-remote-ssh
uses: azure/CLI@v1
with:
azcliversion: ${{ env.azCliVersion }}
inlineScript: |
echo "Restart remote SSH agent"
az vm user reset-ssh \
--resource-group $resourceGroup \
--name ${{ env.adminVMName }}
- name: Verify system services at admin server
id: veriy-admin-service
run: |
Expand All @@ -341,7 +356,8 @@ jobs:
id: verify-wls-access
run: |
echo "Verifying Weblogic Server Access"
sshpass -p ${wlsPassword} -v ssh -p 22 -o StrictHostKeyChecking=no -o ConnectTimeout=100 -v -tt weblogic@${wlsPublicIP} 'bash -s' < ${{ env.offerName }}/test/scripts/verify-wls-access.sh
echo ${wlsPublicIP}
bash ${{ env.offerName }}/test/scripts/verify-wls-access.sh "${wlsPublicIP}" "7005"
- name: Deploy DB Template to Connect to Azure Postgresql Database
id: enable-postgresql-db
Expand Down
29 changes: 20 additions & 9 deletions src/main/scripts/aadIntegration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function validateInput()

function createAADProvider_model()
{
cat <<EOF >${SCRIPT_PWD}/configure-active-directory.py
cat <<EOF >${SCRIPT_PATH}/configure-active-directory.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
try:
edit()
Expand Down Expand Up @@ -161,7 +161,7 @@ EOF

function createSSL_model()
{
cat <<EOF >${SCRIPT_PWD}/configure-ssl.py
cat <<EOF >${SCRIPT_PATH}/configure-ssl.py
# Connect to the AdminServer.
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
try:
Expand Down Expand Up @@ -241,8 +241,8 @@ function importAADCertificate()
function configureSSL()
{
echo "configure ladp ssl"
. $oracleHome/oracle_common/common/bin/setWlstEnv.sh
java $WLST_ARGS weblogic.WLST ${SCRIPT_PWD}/configure-ssl.py
sudo chown -R ${USER_ORACLE}:${GROUP_ORACLE} ${SCRIPT_PATH}
runuser -l ${USER_ORACLE} -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${SCRIPT_PATH}/configure-ssl.py"

errorCode=$?
if [ $errorCode -eq 1 ]
Expand All @@ -255,8 +255,8 @@ function configureSSL()
function configureAzureActiveDirectory()
{
echo "create Azure Active Directory provider"
. $oracleHome/oracle_common/common/bin/setWlstEnv.sh
java $WLST_ARGS weblogic.WLST ${SCRIPT_PWD}/configure-active-directory.py
sudo chown -R ${USER_ORACLE}:${GROUP_ORACLE} ${SCRIPT_PATH}
runuser -l ${USER_ORACLE} -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${SCRIPT_PATH}/configure-active-directory.py"

errorCode=$?
if [ $errorCode -eq 1 ]
Expand Down Expand Up @@ -304,8 +304,7 @@ function wait_for_admin()
function cleanup()
{
echo "Cleaning up temporary files..."
rm -f ${SCRIPT_PWD}/configure-ssl.py
rm -f ${SCRIPT_PWD}/configure-active-directory.py
rm -f -r ${SCRIPT_PATH}
rm -rf ${SCRIPT_PWD}/security/*
echo "Cleanup completed."
}
Expand All @@ -327,11 +326,21 @@ EOF
fi
}

function createTempFolder()
{
export SCRIPT_PATH="/u01/tmp"
sudo rm -f -r ${SCRIPT_PATH}
sudo mkdir ${SCRIPT_PATH}
sudo rm -rf $SCRIPT_PATH/*
}

export LDAP_USER_NAME='sAMAccountName'
export LDAP_USER_FROM_NAME_FILTER='(&(sAMAccountName=%u)(objectclass=user))'
export JAVA_OPTIONS_TLS_V12="-Djdk.tls.client.protocols=TLSv1.2"
export STRING_ENABLE_TLSV12="Append -Djdk.tls.client.protocols to JAVA_OPTIONS in jdk8"
export SCRIPT_PWD=`pwd`
export USER_ORACLE="oracle"
export GROUP_ORACLE="oracle"

if [ $# -ne 18 ]
then
Expand Down Expand Up @@ -359,7 +368,8 @@ export wlsAdminServerName=${17}
export wlsDomainPath=${18}
export wlsAdminURL=$wlsAdminHost:$wlsAdminPort


validateInput
createTempFolder
echo "check status of admin server"
wait_for_admin

Expand All @@ -378,3 +388,4 @@ echo "Waiting for admin server to be available"
wait_for_admin
echo "Weblogic admin server is up and running"

cleanup
30 changes: 26 additions & 4 deletions src/main/scripts/datasourceConfig-oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function validateInput()
function createJDBCSource_model()
{
echo "Creating JDBC data source with name $jdbcDataSourceName"
cat <<EOF >create_datasource.py
cat <<EOF >${scriptPath}/create_datasource.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
edit("$hostName")
startEdit()
Expand Down Expand Up @@ -122,24 +122,46 @@ try:
resolve()
activate()
except Exception, e:
print "Already datasource with name $jdbcDataSourceName exists"
e.printStackTrace()
dumpStack()
undo('true',defaultAnswer='y')
cancelEdit('y')
destroyEditSession("$hostName",force = true)
raise("$jdbcDataSourceName configuration failed")
destroyEditSession("$hostName",force = true)
disconnect()
EOF
}

function createTempFolder()
{
export scriptPath="/u01/tmp"
sudo rm -f -r ${scriptPath}
sudo mkdir ${scriptPath}
sudo rm -rf $scriptPath/*
}

if [ $# -lt 9 ]
then
usage
exit 1
fi

createTempFolder
validateInput
createJDBCSource_model

. $oracleHome/oracle_common/common/bin/setWlstEnv.sh
sudo chown -R oracle:oracle ${scriptPath}
runuser -l oracle -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${scriptPath}/create_datasource.py"

errorCode=$?
if [ $errorCode -eq 1 ]
then
echo "Exception occurs during DB configuration, please check."
exit 1
fi

java $WLST_ARGS weblogic.WLST create_datasource.py $wlsUserName $wlsPassword $wlsAdminURL $jdbcDataSourceName $dsConnectionURL $dsUser $dsPassword $wlsClusterName
echo "Cleaning up temporary files..."
rm -f -r ${scriptPath}


31 changes: 26 additions & 5 deletions src/main/scripts/datasourceConfig-postgresql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function validateInput()
function createJDBCSource_model()
{
echo "Creating JDBC data source with name $jdbcDataSourceName"
cat <<EOF >create_datasource.py
cat <<EOF >${scriptPath}/create_datasource.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
edit("$hostName")
startEdit()
Expand Down Expand Up @@ -122,12 +122,25 @@ try:
resolve()
activate()
except Exception, e:
print "Already datasource with name $jdbcDataSourceName exists"
e.printStackTrace()
dumpStack()
undo('true',defaultAnswer='y')
cancelEdit('y')
destroyEditSession("$hostName",force = true)
raise("$jdbcDataSourceName configuration failed")
destroyEditSession("$hostName",force = true)
disconnect()
EOF
}

function createTempFolder()
{
export scriptPath="/u01/tmp"
sudo rm -f -r ${scriptPath}
sudo mkdir ${scriptPath}
sudo rm -rf $scriptPath/*
}


# store arguments in a special array
args=("$@")
Expand All @@ -147,12 +160,20 @@ then
exit 1
fi

createTempFolder
validateInput
createJDBCSource_model

. $oracleHome/oracle_common/common/bin/setWlstEnv.sh
sudo chown -R oracle:oracle ${scriptPath}
runuser -l oracle -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${scriptPath}/create_datasource.py"

errorCode=$?
if [ $errorCode -eq 1 ]
then
echo "Exception occurs during DB configuration, please check."
exit 1
fi

java $WLST_ARGS weblogic.WLST create_datasource.py $wlsUserName $wlsPassword $wlsAdminURL $jdbcDataSourceName $dsConnectionURL $dsUser $dsPassword $wlsClusterName

echo "Cleaning up temporary files..."
rm -f -r ${scriptPath}

31 changes: 26 additions & 5 deletions src/main/scripts/datasourceConfig-sqlserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function validateInput()
function createJDBCSource_model()
{
echo "Creating JDBC data source with name $jdbcDataSourceName"
cat <<EOF >create_datasource.py
cat <<EOF >${scriptPath}/create_datasource.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
edit("$hostName")
startEdit()
Expand Down Expand Up @@ -122,24 +122,45 @@ try:
resolve()
activate()
except Exception, e:
print "Already datasource with name $jdbcDataSourceName exists"
e.printStackTrace()
dumpStack()
undo('true',defaultAnswer='y')
cancelEdit('y')
destroyEditSession("$hostName",force = true)
raise("$jdbcDataSourceName configuration failed")
destroyEditSession("$hostName",force = true)
disconnect()
EOF
}

function createTempFolder()
{
export scriptPath="/u01/tmp"
sudo rm -f -r ${scriptPath}
sudo mkdir ${scriptPath}
sudo rm -rf $scriptPath/*
}

if [ $# -lt 9 ]
then
usage
exit 1
fi

createTempFolder
validateInput
createJDBCSource_model

. $oracleHome/oracle_common/common/bin/setWlstEnv.sh
sudo chown -R oracle:oracle ${scriptPath}
runuser -l oracle -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${scriptPath}/create_datasource.py"

errorCode=$?
if [ $errorCode -eq 1 ]
then
echo "Exception occurs during DB configuration, please check."
exit 1
fi

java $WLST_ARGS weblogic.WLST create_datasource.py $wlsUserName $wlsPassword $wlsAdminURL $jdbcDataSourceName $dsConnectionURL $dsUser $dsPassword $wlsClusterName

echo "Cleaning up temporary files..."
rm -f -r ${scriptPath}

16 changes: 13 additions & 3 deletions src/main/scripts/elkIntegration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function validate_input()
# Stack Traces to stdout: true
function create_wls_log_model()
{
cat <<EOF >${SCRIPT_PWD}/configure-wls-log.py
cat <<EOF >${SCRIPT_PATH}/configure-wls-log.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
try:
edit("$hostName")
Expand Down Expand Up @@ -528,7 +528,8 @@ EOF
function configure_wls_log()
{
echo "Configure WebLogic Log"
java $WLST_ARGS weblogic.WLST ${SCRIPT_PWD}/configure-wls-log.py
sudo chown -R ${userOracle}:${groupOracle} ${SCRIPT_PATH}
runuser -l oracle -c ". $oracleHome/oracle_common/common/bin/setWlstEnv.sh; java $WLST_ARGS weblogic.WLST ${SCRIPT_PATH}/configure-wls-log.py"

errorCode=$?
if [ $errorCode -eq 1 ]
Expand Down Expand Up @@ -610,10 +611,18 @@ function shutdown_admin() {
function cleanup()
{
echo "Cleaning up temporary files..."
rm -f ${SCRIPT_PWD}/*.py
rm -f -r ${SCRIPT_PATH}
echo "Cleanup completed."
}

function createTempFolder()
{
export SCRIPT_PATH="/u01/tmp"
sudo rm -f -r ${SCRIPT_PATH}
sudo mkdir ${SCRIPT_PATH}
sudo rm -rf $SCRIPT_PATH/*
}

export SCRIPT_PWD=`pwd`

if [ $# -ne 13 ]
Expand All @@ -622,6 +631,7 @@ then
exit 1
fi

createTempFolder
validate_input

echo "start to configure ELK"
Expand Down

0 comments on commit 691f676

Please sign in to comment.