Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optional workspace and fix dynamic syslog port #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ The fields that you need to fill out are:
| Admin Username | Username for the virtual Machine(s). Do not use special characters. |
| Admin Password | Password for the virtual Machine(s) and for the 'admin' SolOS CLI user. |
| Security Group Name | New or existing security group, where VMR default ports will be made publicly available. |
| Workspace Name | New or existing OMS Log Analytics workspace, where logs and diagnostics are monitored. |
| Workspace Region | Select region to deploy OMS Log Analytics workspace. |
| Workspace Name | New or existing OMS Log Analytics workspace, where logs and diagnostics are monitored. Leave this field empty to not deploy an OMS Workspace. |
| Workspace Region | Select region to deploy OMS Log Analytics workspace. Not used if Workspace Name is empty. |
| DNS Label for LB IP | Used for the public DNS name of the Load Balancer. |
| DNS Label for VM IP | Used for the public DNS name of each Virtual Machine(s). |
| CentOS Version | The CentOS version for deploying the Docker containers. Use CentOS 7.2, 7.3, or 7.4. |
Expand Down
28 changes: 16 additions & 12 deletions azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
},
"workspaceName": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Unique OMS Workspace Name for Log Analytics."
"description": "Unique OMS Workspace Name for Log Analytics. Leave this field empty to not deploy an OMS Workspace."
}
},
"workspaceRegion": {
"type": "string",
"defaultValue": "East US",
"metadata": {
"description": "OMS Workspace Region for Log Analytics."
"description": "OMS Workspace Region for Log Analytics. Not used if Workspace Name is empty."
},
"allowedValues": [
"East US",
Expand Down Expand Up @@ -140,13 +141,16 @@
"OSDiskName": "osdiskfordockersimple",
"dataDiskName": "datadiskfordockersimple",
"nicName": "myVMNicD",
"scriptUrl": "https://raw.githubusercontent.com/SolaceProducts/solace-azure-quickstart-template/master/",
"baseUrl": "https://raw.githubusercontent.com/SolaceProducts/solace-azure-quickstart-template/master/",
"nestedUrl": "[concat(variables('baseUrl'), 'nested/')]",
"scriptsUrl": "[concat(variables('baseUrl'), 'scripts/')]",
"solaceSecurityName": "SolaceSecurity.Template",
"securitySharedTemplateName": "security-shared-resources.json",
"solaceLoadBalancerName": "SolaceLoadBalancer.Template",
"loadBalancerSharedTemplateName": "loadbalancer-shared-resources.json",
"solaceWorkspaceName": "SolaceWorkspace.Template",
"workspaceSharedTemplateName": "workspace-shared-resources.json",
"workspaceEnabledSharedTemplateName": "workspace-enabled-shared-resources.json",
"workspaceDisabledSharedTemplateName": "workspace-disabled-shared-resources.json",
"solaceInstallScriptName": "deploy_vmr.sh",
"sempQueryScriptName": "semp_query.sh",
"publicIPAddressName": "myPublicIPD",
Expand All @@ -171,7 +175,6 @@
"lbID": "[resourceId('Microsoft.Network/loadBalancers',variables('lbName'))]",
"lbPoolName": "vmr-ha-group",
"lbPoolID": "[concat(variables('lbID'),'/backendAddressPools/',variables('lbPoolName'))]",
"dataDiskVolume" : "/dev/sdc",
"dataDisksChoices": {
"0": [
{
Expand Down Expand Up @@ -210,7 +213,7 @@
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('scriptUrl'), variables('securitySharedTemplateName'))]",
"uri": "[concat(variables('nestedUrl'), variables('securitySharedTemplateName'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
Expand All @@ -230,7 +233,7 @@
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('scriptUrl'), variables('loadBalancerSharedTemplateName'))]",
"uri": "[concat(variables('nestedUrl'), variables('loadBalancerSharedTemplateName'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
Expand Down Expand Up @@ -259,7 +262,7 @@
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('scriptUrl'), variables('workspaceSharedTemplateName'))]",
"uri": "[if(empty(parameters('workspaceName')), concat(variables('nestedUrl'), variables('workspaceDisabledSharedTemplateName')), concat(variables('nestedUrl'), variables('workspaceEnabledSharedTemplateName')))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
Expand Down Expand Up @@ -449,6 +452,7 @@
}
},
{
"condition": "[not(empty(parameters('workspaceName')))]",
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'), copyindex(), '/OmsAgentExtension')]",
Expand Down Expand Up @@ -483,7 +487,7 @@
"count": "[variables('numberOfInstances')]"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'), copyindex(), '/extensions/DockerExtension')]"
"[if(empty(parameters('workspaceName')), concat('Microsoft.Compute/virtualMachines/', variables('vmName'), copyindex(), '/extensions/DockerExtension'), concat('Microsoft.Compute/virtualMachines/', variables('vmName'), copyindex(), '/extensions/OmsAgentExtension'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
Expand All @@ -493,12 +497,12 @@
"settings": {
"fileUris": [
"[parameters('solaceVmrUri')]",
"[concat(variables('scriptUrl'), 'scripts/', variables('solaceInstallScriptName'))]",
"[concat(variables('scriptUrl'), 'scripts/', variables('sempQueryScriptName'))]"
"[concat(variables('scriptsUrl'), variables('solaceInstallScriptName'))]",
"[concat(variables('scriptsUrl'), variables('sempQueryScriptName'))]"
]
},
"protectedSettings": {
"commandToExecute": "[concat('mkdir -p -m 600 ', variables('adminPasswordDir'), '; echo ', parameters('adminPassword'), ' > ', variables('adminPasswordFile'), '; bash ', variables('solaceInstallScriptName'), ' -c ', copyindex(), ' -i ', variables('nodeAddressPrefix'), ' -n ', variables('numberOfInstances'), ' -p ', variables('adminPasswordFile'), ' -s ', if(equals(copyindex(), variables('monitorNodeIndex')), '0', parameters('dataDiskSize')), if(equals(copyindex(), variables('monitorNodeIndex')), '', concat(' -v ', variables('dataDiskVolume'))), ' -u ', parameters('solaceVmrUri'))]"
"commandToExecute": "[concat('mkdir -p -m 600 ', variables('adminPasswordDir'), '; echo ', parameters('adminPassword'), ' > ', variables('adminPasswordFile'), '; bash ', variables('solaceInstallScriptName'), ' -c ', copyindex(), ' -i ', variables('nodeAddressPrefix'), ' -n ', variables('numberOfInstances'), ' -p ', variables('adminPasswordFile'), ' -s ', if(equals(copyindex(), variables('monitorNodeIndex')), '0', parameters('dataDiskSize')), if(empty(parameters('workspaceName')), '', concat(' -w ', reference(variables('solaceWorkspaceName')).outputs.workspaceId.value)), ' -u ', parameters('solaceVmrUri'))]"
}
}
}
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions nested/workspace-disabled-shared-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceName": {
"type": "string",
"defaultValue": ""
},
"workspaceRegion": {
"type": "string",
"defaultValue": ""
}
},
"variables": {
},
"outputs": {
"workspaceId": {
"type": "string",
"value": ""
},
"workspaceKey": {
"type": "string",
"value": ""
}
},
"resources": [
]
}
73 changes: 54 additions & 19 deletions scripts/deploy_vmr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ip_prefix=""
number_of_instances=""
password_file=""
disk_size=""
disk_volume=""
workspace_id=""
solace_url=""
DEBUG="-vvvv"
is_primary="false"

verbose=0

while getopts "c:i:n:p:s:v:u:" opt; do
while getopts "c:i:n:p:s:w:u:" opt; do
case "$opt" in
c) current_index=$OPTARG
;;
Expand All @@ -27,7 +27,7 @@ while getopts "c:i:n:p:s:v:u:" opt; do
;;
s) disk_size=$OPTARG
;;
v) disk_volume=$OPTARG
w) workspace_id=$OPTARG
;;
u) solace_url=$OPTARG
;;
Expand All @@ -39,7 +39,8 @@ shift $((OPTIND-1))

verbose=1
echo "`date` current_index=$current_index , ip_prefix=$ip_prefix , number_of_instances=$number_of_instances , \
password_file=$password_file , disk_size=$disk_size , disk_volume=$disk_volume , solace_url=$solace_url , Leftovers: $@"
password_file=$password_file , disk_size=$disk_size , workspace_id=$workspace_id , solace_url=$solace_url , \
Leftovers: $@"
export password=`cat ${password_file}`

#Install the logical volume manager and jq for json parsing
Expand Down Expand Up @@ -208,12 +209,29 @@ docker volume create --name=var
docker volume create --name=softAdb
docker volume create --name=adbBackup

if [ $disk_size == "0" ]; then
if [ ${disk_size} == "0" ]; then
docker volume create --name=diagnostics
docker volume create --name=internalSpool
SPOOL_MOUNT="-v diagnostics:/var/lib/solace/diags -v internalSpool:/usr/sw/internalSpool"
else
echo "`date` Create primary partition on new disk"
# Look for unpartitioned disks
disk_volume=""
DEVS=($(ls -1 /dev/sd*|egrep -v "[0-9]$"))
for DEV in "${DEVS[@]}"; do
# Check each device if there is a "1" partition.
# If not, assume it is not partitioned.
if [ ! -b ${DEV}1 ]; then
echo "`date` INFO: Disk device with no primary partition found"
disk_volume="${DEV}"
break
fi
done
if [ ${disk_volume} == "" ]; then
echo "`date` INFO: Default disk device to /dev/sdc"
disk_volume="/dev/sdc"
fi
echo "`date` INFO: Create primary partition on disk device ${disk_volume} of size ${disk_size} GiB"

(
echo n # Add a new partition
echo p # Primary partition
Expand All @@ -232,6 +250,34 @@ else
SPOOL_MOUNT="-v /opt/vmr/diagnostics:/var/lib/solace/diags -v /opt/vmr/internalSpool:/usr/sw/internalSpool"
fi

LOG_OPT=""
logging_config=""
if [[ ${workspace_id} != "" ]]; then
SYSLOG_CONF="/etc/opt/microsoft/omsagent/${workspace_id}/conf/omsagent.d/syslog.conf"
SYSLOG_PORT=""
if [ -f ${SYSLOG_CONF} ]; then
echo "`date` INFO: Configuration file for syslog found"
SYSLOG_PORT=$(sed -n 's/.*port \(.*\).*/\1/p' $SYSLOG_CONF)
fi
if [[ ${SYSLOG_PORT} == "" ]]; then
echo "`date` INFO: Default syslog port to 25224"
SYSLOG_PORT="25224"
fi
echo "`date` INFO: Configuring logging on syslog port ${SYSLOG_PORT}"
LOG_OPT="--log-driver syslog --log-opt syslog-format=rfc3164 --log-opt syslog-address=udp://127.0.0.1:$SYSLOG_PORT"
logging_config="\
--env logging_debug_output=all \
--env logging_debug_format=graylog \
--env logging_command_output=all \
--env logging_command_format=graylog \
--env logging_system_output=all \
--env logging_system_format=graylog \
--env logging_event_output=all \
--env logging_event_format=graylog \
--env logging_kernel_output=all \
--env logging_kernel_format=graylog"
fi

#Define a create script
tee /root/docker-create <<-EOF
#!/bin/bash
Expand All @@ -243,9 +289,7 @@ docker create \
--ulimit core=-1 \
--ulimit memlock=-1 \
--ulimit nofile=2448:38048 \
--log-driver syslog \
--log-opt syslog-format=rfc3164 \
--log-opt syslog-address=udp://127.0.0.1:25224 \
${LOG_OPT} \
-v $(dirname ${password_file}):/run/secrets \
-v jail:/usr/sw/jail \
-v var:/usr/sw/var \
Expand All @@ -254,16 +298,7 @@ docker create \
${SPOOL_MOUNT} \
--env username_admin_globalaccesslevel=admin \
--env username_admin_passwordfilepath=$(basename ${password_file}) \
--env logging_debug_output=all \
--env logging_debug_format=graylog \
--env logging_command_output=all \
--env logging_command_format=graylog \
--env logging_system_output=all \
--env logging_system_format=graylog \
--env logging_event_output=all \
--env logging_event_format=graylog \
--env logging_kernel_output=all \
--env logging_kernel_format=graylog \
${logging_config} \
${redundancy_config} \
--name=solace solace-app:${VMR_VERSION}
EOF
Expand Down