mirror of
https://github.com/ZwareBear/JFrog-Cloud-Installers.git
synced 2026-01-21 01:06:55 -06:00
Arm Template, Xray. Modify RabbitMQ HA functionality (#133)
* Xray, rabbitMQ HA cluster modifications
This commit is contained in:
@@ -172,18 +172,6 @@
|
|||||||
},
|
},
|
||||||
"visible": true
|
"visible": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "clusterName",
|
|
||||||
"type": "Microsoft.Common.TextBox",
|
|
||||||
"label": "Cluster name",
|
|
||||||
"toolTip": "Cluster name",
|
|
||||||
"defaultValue": "",
|
|
||||||
"constraints": {
|
|
||||||
"required": true,
|
|
||||||
"regex": "^[a-z0-9A-Z]{1,30}$",
|
|
||||||
"validationMessage": "Only alphanumeric characters are allowed, and the value must be 1-30 characters long."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "masterKey",
|
"name": "masterKey",
|
||||||
"type": "Microsoft.Common.PasswordBox",
|
"type": "Microsoft.Common.PasswordBox",
|
||||||
@@ -337,7 +325,6 @@
|
|||||||
"subnetName": "[steps('vmCredential').vnet.subnets.subnet1.name]",
|
"subnetName": "[steps('vmCredential').vnet.subnets.subnet1.name]",
|
||||||
"subnetAddressPrefix": "[steps('vmCredential').vnet.subnets.subnet1.addressPrefix]",
|
"subnetAddressPrefix": "[steps('vmCredential').vnet.subnets.subnet1.addressPrefix]",
|
||||||
"xrayVersion": "[steps('xrayConfig').xrayVersion]",
|
"xrayVersion": "[steps('xrayConfig').xrayVersion]",
|
||||||
"clusterName": "[steps('xrayConfig').clusterName]",
|
|
||||||
"artifactoryURL": "[steps('xrayConfig').artifactoryURL]",
|
"artifactoryURL": "[steps('xrayConfig').artifactoryURL]",
|
||||||
"masterKey": "[steps('xrayConfig').masterKey]",
|
"masterKey": "[steps('xrayConfig').masterKey]",
|
||||||
"joinKey": "[steps('xrayConfig').joinKey]",
|
"joinKey": "[steps('xrayConfig').joinKey]",
|
||||||
|
|||||||
@@ -347,7 +347,7 @@
|
|||||||
"computerNamePrefix": "[variables('namingInfix')]",
|
"computerNamePrefix": "[variables('namingInfix')]",
|
||||||
"adminUsername": "[parameters('adminUsername')]",
|
"adminUsername": "[parameters('adminUsername')]",
|
||||||
"adminPassword": "[parameters('adminPassword')]",
|
"adminPassword": "[parameters('adminPassword')]",
|
||||||
"customData": "[base64(concat('#INSTALL SCRIPT INPUTS\nXRAY_VERSION=', parameters('xrayVersion'),'\nARTIFACTORY_URL=',variables('artifactoryURL'),'\nDB_SERVER=',variables('db_server'),'\nDB_NAME=',variables('db_name'),'\nDB_ADMIN_USER=',variables('db_user'),'\nACTUAL_DB_ADMIN_USER=',variables('actual_db_user'),'\nDB_ADMIN_PASSWD=',variables('db_password'),'\nMASTER_KEY=',variables('masterKey'),'\nLOCATION=',parameters('location'),'\nJOIN_KEY=',variables('joinKey'),'\n'))]"
|
"customData": "[base64(concat('#INSTALL SCRIPT INPUTS\nXRAY_VERSION=', parameters('xrayVersion'),'\nARTIFACTORY_URL=',variables('artifactoryURL'),'\nDB_SERVER=',variables('db_server'),'\nDB_NAME=',variables('db_name'),'\nDB_ADMIN_USER=',variables('db_user'),'\nACTUAL_DB_ADMIN_USER=',variables('actual_db_user'),'\nDB_ADMIN_PASSWD=',variables('db_password'),'\nMASTER_KEY=',variables('masterKey'),'\nLOCATION=',parameters('location'),'\nCLUSTER_NAME=',parameters('clusterName'),'\nJOIN_KEY=',variables('joinKey'),'\n'))]"
|
||||||
},
|
},
|
||||||
"networkProfile": {
|
"networkProfile": {
|
||||||
"networkInterfaceConfigurations": [
|
"networkInterfaceConfigurations": [
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ MASTER_KEY=$(cat /var/lib/cloud/instance/user-data.txt | grep "^MASTER_KEY=" | s
|
|||||||
JOIN_KEY=$(cat /var/lib/cloud/instance/user-data.txt | grep "^JOIN_KEY=" | sed "s/JOIN_KEY=//")
|
JOIN_KEY=$(cat /var/lib/cloud/instance/user-data.txt | grep "^JOIN_KEY=" | sed "s/JOIN_KEY=//")
|
||||||
LOCATION=$(cat /var/lib/cloud/instance/user-data.txt | grep "^LOCATION=" | sed "s/LOCATION=//")
|
LOCATION=$(cat /var/lib/cloud/instance/user-data.txt | grep "^LOCATION=" | sed "s/LOCATION=//")
|
||||||
ARTIFACTORY_URL=$(cat /var/lib/cloud/instance/user-data.txt | grep "^ARTIFACTORY_URL=" | sed "s/ARTIFACTORY_URL=//")
|
ARTIFACTORY_URL=$(cat /var/lib/cloud/instance/user-data.txt | grep "^ARTIFACTORY_URL=" | sed "s/ARTIFACTORY_URL=//")
|
||||||
|
CLUSTER_NAME=$(cat /var/lib/cloud/instance/user-data.txt | grep "^CLUSTER_NAME=" | sed "s/CLUSTER_NAME=//")
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
|
|||||||
sudo add-apt-repository ppa:rmescandon/yq -y
|
sudo add-apt-repository ppa:rmescandon/yq -y
|
||||||
sudo apt update -y
|
sudo apt update -y
|
||||||
sudo apt install yq -y
|
sudo apt install yq -y
|
||||||
|
sudo apt install nmap -y
|
||||||
|
|
||||||
# Create master.key on each node
|
# Create master.key on each node
|
||||||
sudo mkdir -p /opt/jfrog/xray/var/etc/security/
|
sudo mkdir -p /opt/jfrog/xray/var/etc/security/
|
||||||
@@ -28,10 +30,7 @@ export PARTNER_ID=Partner/ACC-007221
|
|||||||
export INTEGRATION_NAME=ARM_xray-template/1.0.0
|
export INTEGRATION_NAME=ARM_xray-template/1.0.0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Xray should have the same join key as the Artifactory instance
|
# Verify if the app is deploying in GovCloud
|
||||||
# Both application should be deployed in the same Virtual Networks
|
|
||||||
HOSTNAME=$(hostname -i)
|
|
||||||
|
|
||||||
regex_location_gov="usgov.*"
|
regex_location_gov="usgov.*"
|
||||||
regex_location_dod="usdod.*"
|
regex_location_dod="usdod.*"
|
||||||
|
|
||||||
@@ -41,13 +40,35 @@ else
|
|||||||
DB_DOMAIN=azure.com
|
DB_DOMAIN=azure.com
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Modify system.yaml file
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.url postgres://${DB_SERVER}.postgres.database.${DB_DOMAIN}:5432/${DB_NAME}?sslmode=disable
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.url postgres://${DB_SERVER}.postgres.database.${DB_DOMAIN}:5432/${DB_NAME}?sslmode=disable
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.username ${DB_USER}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.username ${DB_USER}
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.actualUsername ${ACTUAL_DB_USER}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.actualUsername ${ACTUAL_DB_USER}
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.password ${DB_PASSWORD}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.database.password ${DB_PASSWORD}
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.password JFXR_RABBITMQ_COOKIE
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.password JFXR_RABBITMQ_COOKIE
|
||||||
|
|
||||||
|
# RabbitMQ HA configuration for VMSS
|
||||||
|
HOSTNAME=$(hostname -s)
|
||||||
|
ACTIVE_NODE_NAME=$(echo "$HOSTNAME" | sed 's/......$/000000/')
|
||||||
|
printenv
|
||||||
|
|
||||||
|
if [[ $HOSTNAME =~ 000000 ]];
|
||||||
|
then
|
||||||
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.erlangCookie.value JFXR_RABBITMQ_COOKIE
|
||||||
|
else
|
||||||
|
# Scan the subnet to verify if there are other Xray nodes
|
||||||
|
# Get the first Xray node name, modify to met RabbitMQ requirements, add into system.yaml
|
||||||
|
# Modify system.yaml to make a new RabbitMQ node able to connect to the cluster
|
||||||
|
ACTIVE_NODE_NAME=$(nmap -sn $(hostname -i)/24 | grep -i ${CLUSTER_NAME} | sort | awk 'NR==1{print $5}')
|
||||||
|
RABBITMQ_ACTIVE_NODE=$(cat /etc/hostname | sed 's/......$//g')$(echo $ACTIVE_NODE_NAME | cut -f1 -d"." | sed -e 's/\(^.*\)\(......$\)/\2/' | tr '[:lower:]' '[:upper:]')
|
||||||
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.erlangCookie.value JFXR_RABBITMQ_COOKIE
|
||||||
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.clean Y
|
||||||
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.rabbitMq.active.node.name ${RABBITMQ_ACTIVE_NODE}
|
||||||
|
fi
|
||||||
|
HOSTNAME=$(hostname -i)
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.jfrogUrl ${ARTIFACTORY_URL}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.jfrogUrl ${ARTIFACTORY_URL}
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.security.joinKey ${JOIN_KEY}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.security.joinKey ${JOIN_KEY}
|
||||||
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.security.masterKeyFile /opt/jfrog/xray/var/etc/security/master.key
|
||||||
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.node.ip ${HOSTNAME}
|
yq w -i /var/opt/jfrog/xray/etc/system.yaml shared.node.ip ${HOSTNAME}
|
||||||
|
|
||||||
chown xray:xray -R /opt/jfrog/xray/var/etc/security/* && chown xray:xray -R /opt/jfrog/xray/var/etc/security/
|
chown xray:xray -R /opt/jfrog/xray/var/etc/security/* && chown xray:xray -R /opt/jfrog/xray/var/etc/security/
|
||||||
|
|||||||
Reference in New Issue
Block a user