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

Simple scenario #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions generator/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

#Install Python
#sudo apt install python-minimal

#Install pip
#sudo apt install python-pip

#Install pyyaml
#sudo pip install pyyaml

./deploy.sh simple rgName$(date +%Y%m%d)
1 change: 1 addition & 0 deletions generator/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ RESOURCE_GROUP=$2
python deployment.py parameters/${PARAMETERS_FILE}.yaml

az group create --name $RESOURCE_GROUP --location westus --output table
#az group deployment validate --template-file generatedTemplate.json --resource-group $RESOURCE_GROUP
az group deployment create --verbose --template-file generatedTemplate.json --resource-group $RESOURCE_GROUP --output table
61 changes: 32 additions & 29 deletions generator/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def main():
license = parameters['license']
username = parameters['username']
password = parameters['password']
serverVersion = parameters['serverVersion']
syncGatewayVersion = parameters['syncGatewayVersion']

template={
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
Expand All @@ -28,21 +30,21 @@ def main():
}

for cluster in parameters['clusters']:
template['resources']+=generateCluster(license, username, password, cluster)
template['resources']+=generateCluster(license, username, password, serverVersion, syncGatewayVersion, cluster)

file = open('generatedTemplate.json', 'w')
file.write(json.dumps(template, sort_keys=True, indent=4, separators=(',', ': ')) + '\n')
file.close()

def generateCluster(license, username, password, cluster):
def generateCluster(license, username, password, serverVersion, syncGatewayVersion, cluster):
resources = []
clusterName = cluster['cluster']
region = cluster['region']

resources.append(generateNetworkSecurityGroups(clusterName, region))
resources.append(generateVirtualNetwork(clusterName, region))
for group in cluster['groups']:
resources+=generateGroup(license, username, password, clusterName, region, group)
resources+=generateGroup(license, username, password, clusterName, region, group, serverVersion, syncGatewayVersion)

return resources

Expand Down Expand Up @@ -213,36 +215,37 @@ def generateVirtualNetwork(clusterName, region):
}
return virtualNetwork

def generateGroup(license, username, password, clusterName, region, group):
def generateGroup(license, username, password, clusterName, region, group, serverVersion, syncGatewayVersion):
groupName = group['group']
nodeCount = group['nodeCount']
nodeType = group['nodeType']
diskSize = group['diskSize']
services = group['services']

resources=[]
resources.append(generateServer(region))
resources.append(generateSyncGateway(region))
resources.append(generateServer(clusterName, region, license, serverVersion, username, password, diskSize, nodeCount, nodeType))
resources.append(generateSyncGateway(clusterName, region, license, username, password, nodeCount, nodeType, syncGatewayVersion)) #Probably needs to be moved to the cluster level

return resources

def generateServer():
def generateServer(clusterName, region, license, serverVersion, username, password, diskSize, nodeCount, nodeType):
server={
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "server",
"location": region,
"apiVersion": "2017-03-30",
"dependsOn": [
"Microsoft.Network/virtualNetworks/vnet"
"Microsoft.Network/virtualNetworks/" + clusterName
],
"plan": {
"publisher": "couchbase",
"product": "couchbase-server-enterprise",
"name": "[parameters('license')]"
"name": license
},
"sku": {
"name": "[parameters('vmSize')]",
"name": nodeType,
"tier": "Standard",
"capacity": "[parameters('serverNodeCount')]"
"capacity": nodeCount
},
"properties": {
"overprovision": False,
Expand All @@ -257,7 +260,7 @@ def generateServer():
"imageReference": {
"publisher": "couchbase",
"offer": "couchbase-server-enterprise",
"sku": "[parameters('license')]",
"sku": license,
"version": "latest"
},
"dataDisks": [
Expand All @@ -268,14 +271,14 @@ def generateServer():
"storageAccountType": "Premium_LRS"
},
"caching": "None",
"diskSizeGB": "[parameters('serverDiskSize')]"
"diskSizeGB": diskSize
}
]
},
"osProfile": {
"computerNamePrefix": "server",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
"adminUsername": username,
"adminPassword": password
},
"networkProfile": {
"networkInterfaceConfigurations": [
Expand All @@ -288,7 +291,7 @@ def generateServer():
"name": "ipconfig",
"properties": {
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks/', 'vnet'), '/subnets/subnet')]"
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks/', '{0}'), '/subnets/subnet')]".format(clusterName)
},
"publicipaddressconfiguration": {
"name": "public",
Expand Down Expand Up @@ -320,7 +323,7 @@ def generateServer():
"[concat(variables('extensionUrl'), 'server.sh')]",
"[concat(variables('extensionUrl'), 'util.sh')]"
],
"commandToExecute": "[concat('bash server.sh ', parameters('serverVersion'), ' ', parameters('adminUsername'), ' ', parameters('adminPassword'), ' ', variables('uniqueString'), ' ', parameters('location'))]"
"commandToExecute": "[concat('bash server.sh ', '{1}', ' ', '{2}', ' ', '{3}', ' ', variables('uniqueString'), ' ', '{0}')]".format(region, serverVersion, username, password)
}
}
}
Expand All @@ -331,24 +334,24 @@ def generateServer():
}
return server

def generateSyncGateway():
def generateSyncGateway(clusterName, region, license, username, password, nodeCount, nodeType, syncGatewayVersion):
syncGateway={
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "syncgateway",
"location": "[parameters('location')]",
"location": region,
"apiVersion": "2017-03-30",
"dependsOn": [
"Microsoft.Network/virtualNetworks/vnet"
"Microsoft.Network/virtualNetworks/" + clusterName
],
"plan": {
"publisher": "couchbase",
"product": "couchbase-sync-gateway-enterprise",
"name": "[parameters('license')]"
"name": license
},
"sku": {
"name": "[parameters('vmSize')]",
"name": nodeType,
"tier": "Standard",
"capacity": "[parameters('syncGatewayNodeCount')]"
"capacity": nodeCount
},
"properties": {
"overprovision": False,
Expand All @@ -363,14 +366,14 @@ def generateSyncGateway():
"imageReference": {
"publisher": "couchbase",
"offer": "couchbase-sync-gateway-enterprise",
"sku": "[parameters('license')]",
"sku": license,
"version": "latest"
}
},
"osProfile": {
"computerNamePrefix": "syncgateway",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
"adminUsername": username,
"adminPassword": password
},
"networkProfile": {
"networkInterfaceConfigurations": [
Expand All @@ -383,7 +386,7 @@ def generateSyncGateway():
"name": "ipconfig",
"properties": {
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks/', 'vnet'), '/subnets/subnet')]"
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks/', '{0}'), '/subnets/subnet')]".format(clusterName)
},
"publicipaddressconfiguration": {
"name": "public",
Expand Down Expand Up @@ -415,7 +418,7 @@ def generateSyncGateway():
"[concat(variables('extensionUrl'), 'syncGateway.sh')]",
"[concat(variables('extensionUrl'), 'util.sh')]"
],
"commandToExecute": "[concat('bash syncGateway.sh ', parameters('syncGatewayVersion'))]"
"commandToExecute": "[concat('bash syncGateway.sh ', '{0}')]".format(syncGatewayVersion)
}
}
}
Expand Down Expand Up @@ -445,4 +448,4 @@ def generateOutputs(clusters):

return outputs

main()
main()
2 changes: 1 addition & 1 deletion generator/parameters/simple.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
license: hourly_pricing
license: byol
username: couchbase
password: foo123!
serverVersion: 5.1.0
Expand Down