-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathArcGISDataStore.ps1
336 lines (304 loc) · 14.7 KB
/
ArcGISDataStore.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
Configuration ArcGISDataStore
{
param(
[Parameter(Mandatory=$true)]
[System.String]
$Version,
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[System.Management.Automation.PSCredential]
$ServiceCredential,
[Parameter(Mandatory=$false)]
[System.Boolean]
$ForceServiceCredentialUpdate = $False,
[Parameter(Mandatory=$false)]
[System.Boolean]
$ServiceCredentialIsDomainAccount = $False,
[Parameter(Mandatory=$false)]
[System.Boolean]
$ServiceCredentialIsMSA = $False,
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[System.Management.Automation.PSCredential]
$ServerPrimarySiteAdminCredential,
[Parameter(Mandatory=$False)]
[System.String]
$ContentDirectoryLocation,
[Parameter(Mandatory=$False)]
[System.String]
$PrimaryServerMachine,
[Parameter(Mandatory=$False)]
[System.String]
$PrimaryDataStore,
[Parameter(Mandatory=$False)]
[System.String]
$PrimaryBigDataStore,
[Parameter(Mandatory=$False)]
[System.String]
$PrimaryTileCache,
[Parameter(Mandatory=$False)]
[System.Boolean]
$EnableFailoverOnPrimaryStop = $False,
[Parameter(Mandatory=$false)]
[System.Boolean]
$EnablePointInTimeRecovery = $False,
[Parameter(Mandatory=$False)]
[System.Boolean]
$UsesSSL = $False,
[Parameter(Mandatory=$False)]
[System.Boolean]
$DebugMode = $False
)
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName ArcGIS -ModuleVersion 3.3.1
Import-DscResource -Name ArcGIS_xFirewall
Import-DscResource -Name ArcGIS_Service_Account
Import-DscResource -Name ArcGIS_DataStore
Import-DscResource -Name ArcGIS_WaitForComponent
Node $AllNodes.NodeName
{
if($Node.Thumbprint){
LocalConfigurationManager
{
CertificateId = $Node.Thumbprint
}
}
$VersionArray = $Version.Split(".")
$MajorVersion = $VersionArray[1]
$MinorVersion = if($VersionArray.Count -eq 3){ $VersionArray[2] }else { 0 }
$Depends = @()
ArcGIS_xFirewall DataStore_FirewallRules
{
Name = "ArcGISDataStore"
DisplayName = "ArcGIS Data Store"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("2443")
Protocol = "TCP"
DependsOn = $Depends
}
if(($AllNodes | Where-Object { $_.DataStoreTypes -icontains 'Relational' } | Measure-Object).Count -gt 0){
ArcGIS_xFirewall Relational_DataStore_FirewallRules
{
Name = "ArcGISRelationalDataStore"
DisplayName = "ArcGIS Relational Data Store"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("9876")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += '[ArcGIS_xFirewall]Relational_DataStore_FirewallRules'
$IsMultiMachineDataStore = (($AllNodes | Where-Object { $_.DataStoreTypes -icontains 'Relational' } | Measure-Object).Count -gt 1)
if($IsMultiMachineDataStore)
{
# Allow outbound traffic so that database replication can take place
ArcGIS_xFirewall Relational_DataStore_FirewallRules_OutBound
{
Name = "ArcGISDataStore-Out"
DisplayName = "ArcGIS Relational Data Store Out"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("9876")
Direction = "Outbound"
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += '[ArcGIS_xFirewall]Relational_DataStore_FirewallRules_OutBound'
}
}
if(($AllNodes | Where-Object { $_.DataStoreTypes -icontains 'TileCache' } | Measure-Object).Count -gt 0){
ArcGIS_xFirewall TileCache_DataStore_FirewallRules
{
Name = "ArcGISTileCacheDataStore"
DisplayName = "ArcGIS Tile Cache Data Store"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = if($MajorVersion -gt 7){ ("29079-29082") }else{ ("29080", "29081") }
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += @('[ArcGIS_xFirewall]TileCache_DataStore_FirewallRules')
ArcGIS_xFirewall TileCache_FirewallRules_OutBound
{
Name = "ArcGISTileCacheDataStore-Out"
DisplayName = "ArcGIS TileCache Data Store Out"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = if($MajorVersion -gt 7){ ("29079-29082") }else{ ("29080", "29081") }
Direction = "Outbound"
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += @('[ArcGIS_xFirewall]TileCache_FirewallRules_OutBound')
$TileCacheMachineCount = ($AllNodes | Where-Object { $_.DataStoreTypes -icontains 'TileCache' } | Measure-Object).Count
if(($TileCacheMachineCount -gt 1) -and ($MajorVersion -gt 7)){
ArcGIS_xFirewall MultiMachine_TileCache_DataStore_FirewallRules
{
Name = "ArcGISMultiMachineTileCacheDataStore"
DisplayName = "ArcGIS Multi Machine Tile Cache Data Store"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("4369","29083-29090")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += @('[ArcGIS_xFirewall]MultiMachine_TileCache_DataStore_FirewallRules')
ArcGIS_xFirewall MultiMachine_TileCache_FirewallRules_OutBound
{
Name = "ArcGISMultiMachineTileCacheDataStore-Out"
DisplayName = "ArcGIS Multi Machine TileCache Data Store Out"
DisplayGroup = "ArcGIS TileCache Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("4369","29083-29090")
Direction = "Outbound"
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += @('[ArcGIS_xFirewall]MultiMachine_TileCache_FirewallRules_OutBound')
}
}
if(($AllNodes | Where-Object { $_.DataStoreTypes -icontains 'SpatioTemporal' } | Measure-Object).Count -gt 0)
{
ArcGIS_xFirewall SpatioTemporalDataStore_FirewallRules
{
Name = "ArcGISSpatioTemporalDataStore"
DisplayName = "ArcGIS SpatioTemporal Data Store"
DisplayGroup = "ArcGIS Data Store"
Ensure = 'Present'
Access = "Allow"
State = "Enabled"
Profile = ("Domain","Private","Public")
LocalPort = ("9320", "9220")
Protocol = "TCP"
DependsOn = $Depends
}
$Depends += '[ArcGIS_xFirewall]SpatioTemporalDataStore_FirewallRules'
}
ArcGIS_Service_Account ArcGIS_DataStore_RunAs_Account
{
Name = 'ArcGIS Data Store'
RunAsAccount = $ServiceCredential
Ensure = 'Present'
DependsOn = $Depends
DataDir = $ContentDirectoryLocation #DataStoreSpatioTemporalDataDirectory <- Needs to be checked if network location
IsDomainAccount = $ServiceCredentialIsDomainAccount
IsMSAAccount = $ServiceCredentialIsMSA
ForceRunAsAccountUpdate = $ForceServiceCredentialUpdate
SetStartupToAutomatic = $True
}
$Depends += '[ArcGIS_Service_Account]ArcGIS_DataStore_RunAs_Account'
$IsStandByRelational = (($Node.NodeName -ine $PrimaryDataStore) -and $Node.DataStoreTypes -icontains 'Relational')
if($IsStandByRelational)
{
if($UsesSSL){
ArcGIS_WaitForComponent "WaitForRelationalDataStore$($PrimaryDataStore)"{
Component = "DataStore"
InvokingComponent = "DataStore"
ComponentHostName = (Get-FQDN $PrimaryServerMachine)
ComponentContext = "arcgis"
Credential = $ServerPrimarySiteAdminCredential
Ensure = "Present"
RetryIntervalSec = 60
RetryCount = 100
}
$DependsOn += "[ArcGIS_WaitForComponent]WaitForRelationalDataStore$($PrimaryDataStore)"
}else{
WaitForAll "WaitForAllRelationalDataStore$($PrimaryDataStore)"
{
ResourceName = "[ArcGIS_DataStore]DataStore$($PrimaryDataStore)"
NodeName = $PrimaryDataStore
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllRelationalDataStore$($PrimaryDataStore)"
}
}
if(($PrimaryBigDataStore -ine $Node.NodeName) -and ($Node.DataStoreTypes -icontains 'SpatioTemporal'))
{
if($UsesSSL){
ArcGIS_WaitForComponent "WaitForBigDataStore$($PrimaryBigDataStore)"{
Component = "SpatioTemporal"
InvokingComponent = "DataStore"
ComponentHostName = (Get-FQDN $PrimaryServerMachine)
ComponentContext = "arcgis"
Credential = $ServerPrimarySiteAdminCredential
Ensure = "Present"
RetryIntervalSec = 60
RetryCount = 100
}
$DependsOn += "[ArcGIS_WaitForComponent]WaitForBigDataStore$($PrimaryBigDataStore)"
}else{
WaitForAll "WaitForAllBigDataStore$($PrimaryBigDataStore)"{
ResourceName = "[ArcGIS_DataStore]DataStore$($PrimaryBigDataStore)"
NodeName = $PrimaryBigDataStore
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllBigDataStore$($PrimaryBigDataStore)"
}
}
if(($PrimaryTileCache -ine $Node.NodeName) -and ($Node.DataStoreTypes -icontains 'TileCache'))
{
if($UsesSSL){
ArcGIS_WaitForComponent "WaitForTileCache$($PrimaryTileCache)"{
Component = "TileCache"
InvokingComponent = "DataStore"
ComponentHostName = (Get-FQDN $PrimaryServerMachine)
ComponentContext = "arcgis"
Credential = $ServerPrimarySiteAdminCredential
Ensure = "Present"
RetryIntervalSec = 60
RetryCount = 100
}
$DependsOn += "[ArcGIS_WaitForComponent]WaitForTileCache$($PrimaryTileCache)"
}else{
WaitForAll "WaitForAllTileCache$($PrimaryTileCache)"{
ResourceName = "[ArcGIS_DataStore]DataStore$($PrimaryTileCache)"
NodeName = $PrimaryTileCache
RetryIntervalSec = 60
RetryCount = 100
DependsOn = $Depends
}
$Depends += "[WaitForAll]WaitForAllTileCache$($PrimaryTileCache)"
}
}
ArcGIS_DataStore "DataStore$($Node.NodeName)"
{
DatastoreMachineHostName = (Get-FQDN $Node.NodeName)
Ensure = 'Present'
SiteAdministrator = $ServerPrimarySiteAdminCredential
ServerHostName = (Get-FQDN $PrimaryServerMachine)
ContentDirectory = $ContentDirectoryLocation
DependsOn = $Depends
IsStandby = $IsStandByRelational
DataStoreTypes = $Node.DataStoreTypes
EnableFailoverOnPrimaryStop = $EnableFailoverOnPrimaryStop
IsTileCacheDataStoreClustered = (($TileCacheMachineCount -gt 2) -or ($MajorVersion -eq 8 -and $MinorVersion -eq 0))
PITRState = if($EnablePointInTimeRecovery){ "Enabled" }else{ "Disabled" }
}
}
}