This repository was archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathmasterOrchestration.ps1
176 lines (130 loc) · 6.83 KB
/
masterOrchestration.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# VDC Master Script
## ONLY EDIT THE BELOW LINE (LINE 4)##
$inputFile = (Get-Content -Path C:\inputFile.json) | ConvertFrom-Json
# Set the variables that will not change through the deployments of the VDC toolkit
$env:numShrdSvcs = $inputFile.sharedservices.Count
$env:numMSVDI = $inputFile.MSVDI.Count
$ENV:AZURE_DISCOVERY_URL = $inputFile.azureDiscoveryURL
$ENV:AZURE_SENTINEL = $inputFile.azureSentinel
$ENV:ORGANIZATION_NAME = $inputFile.organizationName
$ENV:AZURE_ENVIRONMENT_NAME = $inputFile.azureEnvironmentName
$ENV:TENANT_ID = $inputFile.tenantID
$ENV:HUB_SUB_ID = $inputFile.SharedServices.hub1.subscriptionID
#Location for artifact storage account
$ENV:ARTIFACT_LOCATION = $inputFile.SharedServices.hub1.location
Write-Host "Welcome to the VDC toolkit deployment. Starting the deployment for $ENV:ORGANIZATION_NAME organization. " -ForegroundColor Green
Write-Host `n"You choose to deploy $ENV:numShrdSvcs Shared Service environments." -ForegroundColor Cyan
Write-Host `n"You choose to deploy $ENV:numMSVDI MS-VDI environments." -ForegroundColor Cyan
Function Get-newEnvVariablesSS {
# The below arrays will hold all the env variables for each MS-VDI deployment
$adminUserPWD=@()
$domainAdminUsername=@()
$domainAdminPWD=@()
# The loop below will determine all the env variables for each deployment
For ($i=0; $i -lt $env:numShrdSvcs; $i++) {
$int = $i+1
$hub = "hub" + $int
Write-Host `n"Enter the following secrets for $hub :" -Foregroundcolor Cyan
$ADMIN_USER_PWD = Read-Host -Prompt "What is the VM Admin Password for the $hub deployment? `nEnter 'Random' for a random password"
$adminUserPWD += $ADMIN_USER_PWD
$DOMAIN_ADMIN_USERNAME = Read-Host -Prompt "What is the Domain Account UserName for the $hub deployment?"
$domainAdminUsername += $DOMAIN_ADMIN_USERNAME
$DOMAIN_ADMIN_USER_PWD = Read-Host -Prompt "What is the Domain Account Admin Password for the $hub deployment? `nEnter 'Random' for a random password"
$domainAdminPWD += $DOMAIN_ADMIN_USER_PWD
}
return $adminUserPWD, $domainAdminUsername, $domainAdminPWD
}
Function Get-newEnvVariablesMSVDI {
# The below arrays will hold all the env variables for each MS-VDI deployment
$adminUserPWDMsVDI=@()
$domainAdminUsernameMsVDI=@()
$domainAdminPWDMsVDI=@()
# The loop below will determine all the env variables for each deployment
For ($i=0; $i -lt $env:numMSVDI; $i++) {
$int = $i+1
$msvdi = "MSVDI" + $int
Write-Host `n"Enter the following secrets for $msvdi :" -Foregroundcolor Cyan
$ADMIN_USER_PWD = Read-Host -Prompt "What is the VM Admin Password for the $msvdi deployment? `nEnter 'Random' for a random password"
$adminUserPWDMsVDI += $ADMIN_USER_PWD
$DOMAIN_ADMIN_USERNAME = Read-Host -Prompt "What is the Domain Account UserName for the $msvdi deployment?"
$domainAdminUsernameMsVDI += $DOMAIN_ADMIN_USERNAME
$DOMAIN_ADMIN_USER_PWD = Read-Host -Prompt "What is the Domain Account Admin Password for the $msvdi deployment? `nEnter 'Random' for a random password"
$domainAdminPWDMsVDI += $DOMAIN_ADMIN_USER_PWD
}
return $adminUserPWDMsVDI, $domainAdminUsernameMsVDI, $domainAdminPWDMsVDI
}
# Get env secrets for Shared Services
$adminUserPWD, $domainAdminUsername, $domainAdminPWD = Get-newEnvVariablesSS
# Get env secrets for MSVDI
$adminUserPWDMsVDI, $domainAdminUsernameMsVDI, $domainAdminPWDMsVDI = Get-newEnvVariablesMSVDI
For($i=0; $i -lt $env:numShrdSvcs; $i++) {
$int = $i+1
$hub = "hub$int"
Write-Host `n"Setting Environment Variables for $hub" -ForegroundColor Green
$ENV:AZURE_LOCATION = $inputFile.SharedServices.$hub.location
$ENV:SUBSCRIPTION_ID = $inputFile.SharedServices.$hub.subscriptionID
$ENV:KEYVAULT_MANAGEMENT_USER_ID = $inputFile.SharedServices.$hub.keyvaultobjectID
$ENV:DEVOPS_SERVICE_PRINCIPAL_USER_ID = $inputFile.SharedServices.$hub.devopsID
$ENV:ADMIN_USER_SSH = $inputFile.SharedServices.$hub.adminSSHPubKey
$ENV:FolderName = $inputFile.SharedServices.$hub.folderName
$ENV:ADMIN_USER_NAME = $inputFile.SharedServices.$hub.vmAdminUserName
$ENV:ADMIN_USER_PWD = $adminUserPWD[$i]
$ENV:DOMAIN_ADMIN_USER_PWD = $domainAdminPWD[$i]
$ENV:DOMAIN_ADMIN_USERNAME = $domainAdminUsername[$i]
Write-Host `n"Starting the deployment for $hub. Orchestration using directory folder: $ENV:FolderName"
Write-Host $ENV:ADMIN_USER_NAME
Write-Host $ENV:ADMIN_USER_PWD
Write-Host $ENV:AZURE_LOCATION
Write-Host $ENV:SUBSCRIPTION_ID
Write-Host $ENV:FolderName
Write-Host $ENV:AZURE_SENTINEL
Write-Host $ENV:AZURE_DISCOVERY_URL
Write-Host $ENV:ORGANIZATION_NAME
Write-Host $ENV:DOMAIN_ADMIN_USER_PWD
Write-Host $ENV:DOMAIN_ADMIN_USERNAME
Write-Host $ENV:KEYVAULT_MANAGEMENT_USER_ID
Write-Host $ENV:DEVOPS_SERVICE_PRINCIPAL_USER_ID
Write-Host $ENV:AZURE_ENVIRONMENT_NAME
Write-Host $ENV:ADMIN_USER_SSH
Write-Host $ENV:TENANT_ID
sleep -Seconds 5
./Orchestration/OrchestrationService/Pre_req_script.ps1
sleep -Seconds 5
./Orchestration/OrchestrationService/ModuleConfigurationDeployment.ps1 -DefinitionPath ./Environments/$env:folderName/definition.json
sleep -Seconds 5
}
For($i=0; $i -lt $env:numMSVDI; $i++) {
$int = $i+1
$MSVDI = "MSVDI$int"
Write-Host `n"Setting Environment Variables for $MSVDI" -ForegroundColor Green
$ENV:AZURE_LOCATION = $inputFile.MSVDI.$MSVDI.location
$ENV:SUBSCRIPTION_ID = $inputFile.MSVDI.$MSVDI.subscriptionID
$ENV:KEYVAULT_MANAGEMENT_USER_ID = $inputFile.MSVDI.$MSVDI.keyvaultobjectID
$ENV:DEVOPS_SERVICE_PRINCIPAL_USER_ID = $inputFile.MSVDI.$MSVDI.devopsID
$ENV:ADMIN_USER_SSH = $inputFile.MSVDI.$MSVDI.adminSSHPubKey
$ENV:FolderName = $inputFile.MSVDI.$MSVDI.folderName
$ENV:ADMIN_USER_NAME = $inputFile.MSVDI.$MSVDI.vmAdminUserName
$ENV:ADMIN_USER_PWD = $adminUserPWD[$i]
$ENV:DOMAIN_ADMIN_USER_PWD = $domainAdminPWD[$i]
$ENV:DOMAIN_ADMIN_USERNAME = $domainAdminUsername[$i]
Write-Host `n"Starting the deployment for $MSVDI. Orchestration using directory folder: $ENV:FolderName"
./Orchestration/OrchestrationService/Pre_req_script.ps1
sleep -Seconds 5
./Orchestration/OrchestrationService/ModuleConfigurationDeployment.ps1 -DefinitionPath ./Environments/$env:Foldername/definition.json
sleep -Seconds 5
Write-Host $ENV:ADMIN_USER_NAME
Write-Host $ENV:ADMIN_USER_PWD
Write-Host $ENV:AZURE_LOCATION
Write-Host $ENV:SUBSCRIPTION_ID
Write-Host $ENV:FolderName
Write-Host $ENV:AZURE_SENTINEL
Write-Host $ENV:AZURE_DISCOVERY_URL
Write-Host $ENV:ORGANIZATION_NAME
Write-Host $ENV:DOMAIN_ADMIN_USER_PWD
Write-Host $ENV:DOMAIN_ADMIN_USERNAME
Write-Host $ENV:KEYVAULT_MANAGEMENT_USER_ID
Write-Host $ENV:DEVOPS_SERVICE_PRINCIPAL_USER_ID
Write-Host $ENV:AZURE_ENVIRONMENT_NAME
Write-Host $ENV:ADMIN_USER_SSH
Write-Host $ENV:TENANT_ID
}