-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDeployAzureRmH2oCluster.ps1
138 lines (116 loc) · 4.65 KB
/
DeployAzureRmH2oCluster.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<#
SYNOPSYS
DeployAzureRmH2oCluster.ps1 (Test version V1.0.1)
This script creates an H2O cluster on an Azure Resource Group.
The parameters passed to the deployment are:
- Storage Account Type. DS-series VMs must be deployed in Premium_LRS in order to have an SSD OS disk.
Available types are:
- Standard_LRS
- Premium_LRS
- Virtual Machine Size. Available sizes are:
- Standard_DS1_v2
- Standard_DS2_v2
- Standard_DS3_v2
- Standard_DS4_v2
- Standard_DS5_v2
- Standard_DS11_v2
- Standard_DS12_v2
- Standard_DS13_v2
- Standard_DS14_v2
- Scale Number: The number of h2o nodes to provision in the cluster
- Administrator username
- Administrator password
To run this script, download the file azuredeploy.json from the url
https://github.com/pablomarin/H2OCluster-azure-template/blob/master/azuredeploy.json
or run this command in powershell:
curl -OutFile DeployAzureRmH2oCluster.ps1 https://raw.githubusercontent.com/pablomarin/H2OCluster-azure-template/master/DeployAzureRmH2oCluster.ps1
#>
##########################
# json template location #
##########################
$h2oClusterPath = ""
##########################
# Script Variables #
##########################
$resourceGroupName = ""
##########################
# Template Parameters #
# Change at will #
##########################
$parameters = @{
"storageAccountType" = "Premium_LRS"
"vmSize" = "Standard_DS2_v2"
"adminUserName" = "h2oadmin"
"adminPassword" = "********"
"scaleNumber" = 3
}
##########################
# Begin of Script #
##########################
Write-Host -ForegroundColor Yellow "H2O Azure Cluster Provisioning Script`r`n`r`n"
# Login to Azure
Login-AzureRmAccount
# Get template location
$fileExists = Test-Path -Path $h2oClusterPath
while (!$fileExists)
{
Write-Host -ForegroundColor Green "Type the json template location on this computer:"
$h2oClusterPath = Read-Host ""
$fileExists = Test-Path $h2oClusterPath
if ($fileExists)
{
Write-Host -ForegroundColor Green "File location verified. Continuing...`r`n"
}
else
{
Write-Host -ForegroundColor Red "File Not Found. Check the Make sure the file exists in the path specified or try a different one.`r`n"
}
}
#Get resource group name
if ([string]::IsNullOrEmpty($resourceGroupName))
{
Write-Host -ForegroundColor Green "Enter the Resource Group Name:"
$resourceGroupName = Read-Host ""
$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue
if ($resourceGroup -eq $null)
{
Write-Host -ForegroundColor Green "Resource Group does not exist. Creating...`r`n"
# Get location
$locationSet = $false
do
{
$locations = (Get-AzureRmLocation -WarningAction SilentlyContinue).Location
Write-Host -ForegroundColor Green "`r`nChoose one of the locations listed below:"
for ($i = 0; $i -lt $locations.Count; $i++)
{
Write-Host -ForegroundColor Green " [$($i + 1)] - $($locations[$i])"
}
$locationIndex = Read-Host ""
try
{
$location = $locations[$i - 1]
Write-Host -ForegroundColor Green "You selected '$location'. Press [c] to change or Enter to continue:"
$change = Read-Host ""
if ([string]::IsNullOrEmpty($change))
{
$locationSet = $true
}
}
catch
{
Write-Host -ForegroundColor Red "The option you selected is not valid. Try again.`r`n"
}
}
while (!$locationSet)
Write-Host -ForegroundColor Green "Creating Resource Group $resourceGroupName in $location..."
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location -Verbose -Force -ErrorAction Stop
}
}
else
{
Write-Host -ForegroundColor Green "Getting resource group '$resourceGroupName'..."
$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName -Verbose -ErrorAction Stop
}
Test-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -Mode Incremental -TemplateParameterObject $parameters -TemplateFile $h2oClusterPath -Verbose -ErrorAction Stop
$deploymentName = "H2OCluster-$((Get-Date).Ticks)"
New-AzureRmResourceGroupDeployment -Name $deploymentName -ResourceGroupName $resourceGroupName -Mode Incremental -TemplateParameterObject $parameters -TemplateFile $h2oClusterPath -Force -Verbose -ErrorAction Stop