-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 20fbd5f
Showing
17 changed files
with
1,103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
03-test-vm.bicepparam | ||
01-prereq.bicepparam | ||
02-cbs.bicepparam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
echoerr() { printf "\033[0;31m%s\n\033[0m" "$*" >&2; } | ||
echosuccess() { printf "\033[0;32m%s\n\033[0m" "$*" >&2; } | ||
|
||
# Install the az (with bicep) | ||
echo "Installing tools" | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
|
||
|
||
#4.5. Install the Azure CLI packages, jq, .NET, zip | ||
if [[ "$OSTYPE" =~ ^linux ]]; then | ||
sudo apt -qy install jq | ||
fi | ||
|
||
if [[ "$OSTYPE" =~ ^darwin ]]; then | ||
brew help | ||
if [[ $? != 0 ]] ; then | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
else | ||
brew update | ||
fi | ||
brew install jq | ||
fi | ||
|
||
# check installed tooling | ||
echo "Testing tools:"; | ||
az version | ||
if [ $? == 0 ]; then | ||
echosuccess "[.] az cli tool...OK"; | ||
else | ||
echoerr "Error with 'az cli' tool!"; | ||
exit 1; | ||
fi | ||
|
||
|
||
az bicep version | ||
if [ $? == 0 ]; then | ||
echosuccess "[.] bicep support...OK"; | ||
else | ||
echo "Installing bicep" | ||
az bicep install | ||
exit 1; | ||
fi | ||
|
||
jq --version | ||
if [ $? == 0 ]; then | ||
echosuccess "[.] jq tool...OK"; | ||
else | ||
echoerr "Error with 'jq' tool!"; | ||
exit 1; | ||
fi | ||
|
||
echo "Asking user to log in..."; | ||
# ask user for login | ||
az login | ||
if [ $? == 0 ]; then | ||
echosuccess " | ||
Your machine should be ready! Now proceed with ./deploy.sh script | ||
"; | ||
else | ||
echoerr "Login into Azure failed!"; | ||
exit 1; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
SHOW_DEBUG_OUTPUT=false | ||
|
||
escape_quotes(){ | ||
echo $@ | sed s/'"'/'\\"'/g | ||
} | ||
|
||
|
||
echoerr() { printf "\033[0;31m%s\n\033[0m" "$*" >&2; } | ||
echosuccess() { printf "\033[0;32m%s\n\033[0m" "$*" >&2; } | ||
|
||
|
||
# Read the bicep parameters | ||
parametersfilename='01-prereq.bicepparam' | ||
|
||
echo " " | ||
echo " " | ||
echo " CBS DEPLOYMENT - PREREQUISITES " | ||
echo " " | ||
echo " " | ||
echo " " | ||
|
||
|
||
echo "Deploying required infrastructure" | ||
|
||
paramsJson=`bicep build-params $parametersfilename --stdout | jq -r ".parametersJson"` | ||
|
||
|
||
location=`echo $paramsJson | jq -r ".parameters.location.value"` | ||
|
||
# Deploy our infrastructure | ||
output=$(az deployment sub create \ | ||
--name "CBS-deploy-prereq-bicep-sh" \ | ||
--location $location \ | ||
--template-file "templates/prerequisites.bicep" \ | ||
--parameters $parametersfilename | ||
) | ||
|
||
|
||
subscriptionId=`echo $output | jq -r '.properties.outputs.subscriptionId.value'` | ||
mainRgName=`echo $output | jq -r '.properties.outputs.mainRgName.value'` | ||
arrayVnetId=`echo $output | jq -r '.properties.outputs.arrayVnetId.value'` | ||
arrayVnetName=`echo $output | jq -r '.properties.outputs.arrayVnetName.value'` | ||
vnetMngmtUserManagedIdentityId=`echo $output | jq -r '.properties.outputs.vnetMngmtUserManagedIdentityId.value'` | ||
|
||
echo " -------------------------------------------------------" | ||
echo "| Subscription Id | ${subscriptionId} " | ||
echo "| Main resource group | ${mainRgName}" | ||
echo " -------------------------------------------------------" | ||
echo "" | ||
echo "" | ||
echo " -------- Array virtual network (vNET) --------" | ||
echo "| vNET name | ${arrayVnetName}" | ||
echo "| vNET id | ${arrayVnetId}" | ||
echo " ----------------------------------------------" | ||
|
||
|
||
echo " -------- User managed identity --------" | ||
echo "| Resource Id | ${vnetMngmtUserManagedIdentityId}" | ||
echo " ----------------------------------------------" | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "" | ||
echosuccess "The deployment of prerequisities has been completed. Now you can proceed to deployment of CBS itself with *02-deploy-cbs.sh*." | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using 'templates/prerequisites.bicep' | ||
|
||
param location = 'westeurope' | ||
param resourceGroupName = 'your-resource-group-name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using 'templates/cbs-managed-app.bicep' | ||
|
||
param location = 'westeurope' | ||
param resourceName = 'my-resource-name' | ||
param resourceGroupName = 'your-resource-group-name' | ||
param alertRecipients = '[email protected]' | ||
param arrayName = 'my-array-name' | ||
param licenseKey = 'CBS-TRIAL-LICENSE' | ||
param cbsModelSku = 'V20MUR1' | ||
param orgDomain = 'myorgdomain.dev' | ||
param managedUserIdentityId = '/subscriptions/<subscriptionId>/resourceGroups/<rgName>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<uminame>' | ||
param vnetName = 'my-vnet-name' | ||
param availabilityZone = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
SHOW_DEBUG_OUTPUT=false | ||
|
||
escape_quotes(){ | ||
echo $@ | sed s/'"'/'\\"'/g | ||
} | ||
|
||
|
||
curlwithcode() { | ||
code=0 | ||
# Run curl in a separate command, capturing output of -w "%{http_code}" into statuscode | ||
# and sending the content to a file with -o >(cat >/tmp/curl_body) | ||
statuscode=$(curl -w "%{http_code}" \ | ||
-o >(cat >/tmp/curl_body) \ | ||
"$@" | ||
) || code="$?" | ||
|
||
body="$(cat /tmp/curl_body)" | ||
echo "{\"statusCode\": $statuscode," | ||
echo "\"exitCode\": $code," | ||
echo "\"body\": \"$(escape_quotes $body)\"}" | ||
} | ||
|
||
echoerr() { printf "\033[0;31m%s\n\033[0m" "$*" >&2; } | ||
echosuccess() { printf "\033[0;32m%s\n\033[0m" "$*" >&2; } | ||
|
||
|
||
# Read the bicep parameters | ||
parametersfilename='./02-cbs.bicepparam' | ||
|
||
echo " " | ||
echo " " | ||
echo " CBS DEPLOYMENT " | ||
echo " " | ||
echo " " | ||
echo " " | ||
|
||
|
||
|
||
echo "Deploying CBS managed app" | ||
|
||
paramsJson=`bicep build-params $parametersfilename --stdout | jq -r ".parametersJson"` | ||
|
||
|
||
location=`echo $paramsJson | jq -r ".parameters.location.value"` | ||
resourceGroupName=`echo $paramsJson | jq -r ".parameters.resourceGroupName.value"` | ||
|
||
# Deploy our infrastructure | ||
output=$(az deployment group create \ | ||
--name "CBS-deploy-sh" \ | ||
--resource-group $resourceGroupName \ | ||
--template-file "templates/cbs-managed-app.bicep" \ | ||
--parameters $parametersfilename | ||
) | ||
|
||
cbsmanagementLbIp=`echo $output | jq -r '.properties.outputs.cbsmanagementLbIp.value'` | ||
cbsmanagementEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsmanagementEndpointCT0.value'` | ||
cbsmanagementEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsmanagementEndpointCT1.value'` | ||
|
||
cbsreplicationEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsreplicationEndpointCT0.value'` | ||
cbsreplicationEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsreplicationEndpointCT1.value'` | ||
|
||
cbsiSCSIEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsiSCSIEndpointCT0.value'` | ||
cbsiSCSIEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsiSCSIEndpointCT1.value'` | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "" | ||
echosuccess "The deployment of CBS managed application has been completed." | ||
echo "" | ||
|
||
echo " ******** Array parameters ********" | ||
|
||
echo "" | ||
echo "" | ||
echo " -------- Endpoints for management -------------" | ||
echo " Load balancer IP | ${cbsmanagementLbIp}" | ||
echo " CT0 IP address | ${cbsmanagementEndpointCT0}" | ||
echo " CT1 IP address | ${cbsmanagementEndpointCT1}" | ||
echo " -----------------------------------------------" | ||
|
||
echo "" | ||
echo "" | ||
echo " --------- Endpoints for replication -----------" | ||
echo " CT0 IP address | ${cbsreplicationEndpointCT0}" | ||
echo " CT1 IP address | ${cbsreplicationEndpointCT1}" | ||
echo " -----------------------------------------------" | ||
|
||
echo "" | ||
echo "" | ||
echo " ------------ Endpoints for iSCSI --------------" | ||
echo " CT0 IP address | ${cbsiSCSIEndpointCT0}" | ||
echo " CT1 IP address | ${cbsiSCSIEndpointCT1}" | ||
echo " -----------------------------------------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
SHOW_DEBUG_OUTPUT=false | ||
|
||
escape_quotes(){ | ||
echo $@ | sed s/'"'/'\\"'/g | ||
} | ||
|
||
|
||
curlwithcode() { | ||
code=0 | ||
# Run curl in a separate command, capturing output of -w "%{http_code}" into statuscode | ||
# and sending the content to a file with -o >(cat >/tmp/curl_body) | ||
statuscode=$(curl -w "%{http_code}" \ | ||
-o >(cat >/tmp/curl_body) \ | ||
"$@" | ||
) || code="$?" | ||
|
||
body="$(cat /tmp/curl_body)" | ||
echo "{\"statusCode\": $statuscode," | ||
echo "\"exitCode\": $code," | ||
echo "\"body\": \"$(escape_quotes $body)\"}" | ||
} | ||
|
||
echoerr() { printf "\033[0;31m%s\n\033[0m" "$*" >&2; } | ||
echosuccess() { printf "\033[0;32m%s\n\033[0m" "$*" >&2; } | ||
|
||
|
||
# Read the bicep parameters | ||
parametersfilename='./03-test-vm.bicepparam' | ||
|
||
echo " " | ||
echo " " | ||
echo " TEST VM DEPLOYMENT " | ||
echo " " | ||
echo " " | ||
echo " " | ||
|
||
|
||
|
||
echo "Deploying the VM for testing" | ||
myIpAddress=`curl ifconfig.me 2> /dev/null` | ||
|
||
paramsJson=`bicep build-params $parametersfilename --stdout | jq -r ".parametersJson"` | ||
|
||
tmpJsonFilename='tmp.json' | ||
resourceGroupName=`echo $paramsJson | jq -r ".parameters.resourceGroupName.value"` | ||
(echo $paramsJson | sed "s/\$myIpAddress/$myIpAddress/") > $tmpJsonFilename | ||
|
||
# Deploy our infrastructure | ||
output=$(az deployment group create \ | ||
--name "test-vm-deploy-sh" \ | ||
--resource-group $resourceGroupName \ | ||
--template-file "templates/test-vm.bicep" \ | ||
--parameters @$tmpJsonFilename | ||
) | ||
|
||
rm $tmpJsonFilename | ||
|
||
cbsmanagementLbIp=`echo $output | jq -r '.properties.outputs.cbsmanagementLbIp.value'` | ||
cbsmanagementEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsmanagementEndpointCT0.value'` | ||
cbsmanagementEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsmanagementEndpointCT1.value'` | ||
|
||
cbsreplicationEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsreplicationEndpointCT0.value'` | ||
cbsreplicationEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsreplicationEndpointCT1.value'` | ||
|
||
cbsiSCSIEndpointCT0=`echo $output | jq -r '.properties.outputs.cbsiSCSIEndpointCT0.value'` | ||
cbsiSCSIEndpointCT1=`echo $output | jq -r '.properties.outputs.cbsiSCSIEndpointCT1.value'` | ||
|
||
|
||
echo "" | ||
echo "" | ||
echo "" | ||
echosuccess "The deployment of CBS managed application has been completed." | ||
echo "" | ||
|
||
echo " ******** Array parameters ********" | ||
|
||
echo "" | ||
echo "" | ||
echo " -------- Endpoints for management -------------" | ||
echo "| Load balancer IP | ${cbsmanagementLbIp}" | ||
echo "| CT0 IP address | ${cbsmanagementEndpointCT0}" | ||
echo "| CT1 IP address | ${cbsmanagementEndpointCT1}" | ||
echo " -----------------------------------------------" | ||
|
||
echo "" | ||
echo "" | ||
echo " --------- Endpoints for replication -----------" | ||
echo "| CT0 IP address | ${cbsreplicationEndpointCT0}" | ||
echo "| CT1 IP address | ${cbsreplicationEndpointCT1}" | ||
echo " -----------------------------------------------" | ||
|
||
echo "" | ||
echo "" | ||
echo " ------------ Endpoints for iSCSI --------------" | ||
echo "| CT0 IP address | ${cbsiSCSIEndpointCT0}" | ||
echo "| CT1 IP address | ${cbsiSCSIEndpointCT1}" | ||
echo " -----------------------------------------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Bicep framework for deploying CBS on Azure - EXPERIMENTAL | ||
|
||
## Prerequisites | ||
- bash | ||
- Windows/Linux/MacOS | ||
- `az-cli`, `bicep-cli`, `jq` (all should get installed with setup-machine script) | ||
|
||
## Installation | ||
|
||
### Setup a machine (tooling) | ||
|
||
Just run the `00-setup-machine.sh` script. | ||
|
||
|
||
## Usage | ||
|
||
### 01 - CBS Prerequisites | ||
|
||
The script `01-deploy-prerequisities.sh` deploys all required resources for CBS: | ||
- vNET including subnets | ||
- IP address + NAT gateway for `system` subnet | ||
- user managed identity | ||
- a custom role definition | ||
- a role assignment | ||
|
||
To use prepare inputs in a parameter file `01-prereq.bicepparam` and execute `01-deploy-prerequisities.sh` script. | ||
|
||
|
||
### 02 - CBS Managed App | ||
|
||
The script `02-deploy-cbs.sh` deploys CBS managed application itself. | ||
|
||
To use prepare inputs in a parameter file `02-cbs.bicepparam` and execute `02-deploy-cbs.sh` script. | ||
Please keep in mind, you need to pass into the parameter file `02-cbs.bicepparam` some outputs from `01-deploy-prerequisities.sh` script. | ||
|
||
### 03 - Test VM (WiP) | ||
TODO: description |
Oops, something went wrong.