-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazureDevOps.ps1
173 lines (157 loc) · 6 KB
/
azureDevOps.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
configuration azureDevOps
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration';
Import-DscResource -ModuleName 'xPSDesiredStateConfiguration';
Import-DscResource -ModuleName 'cChoco';
$adoPat = Get-AutomationVariable -Name 'adoPat';
Node $AllNodes.nodeName
{
Script initializeRawDisks
{
GetScript = {
[bool]$rawDisks = [bool]$(Get-Disk | ? {$_.PartitionStyle -eq 'RAW'});
return @{"Result" = $rawDisks};
}
SetScript = {
$rawDisks = Get-Disk | ? {$_.PartitionStyle -eq 'RAW'};
foreach ($disk in $rawDisks)
{
# TODO: identify and assign datadisk name from ARM
$disk | Initialize-Disk -PartitionStyle MBR -PassThru |
New-Partition -AssignDriveLetter -UseMaximumSize |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "dataDisk" -Force;
}
}
TestScript = {
$rawDisks = Get-Disk | ? {$_.PartitionStyle -eq 'RAW'};
if ($rawDisks)
{
return $false;
}
else
{
return $true;
}
}
}
xRemoteFile adoAgent
{
DestinationPath = "$($env:TEMP)\$($configurationData.AllNodes.agentBits)"
Uri = $configurationData.AllNodes.agentUri
DependsOn = "[Script]initializeRawDisks"
}
for ($i = 0; $i -lt $configurationData.AllNodes.agentCount; $i++)
{
File $("agentDirectory" + $i)
{
DestinationPath = $configurationData.AllNodes.agentPath + $i
Type = "Directory"
Ensure = "Present"
DependsOn = "[xRemoteFile]adoAgent"
}
xArchive $("adoAgent" + $i)
{
Path = "$($env:TEMP)\$($configurationData.AllNodes.agentBits)"
Destination = $configurationData.AllNodes.agentPath + $i
Force = $true
Ensure = "Present"
DependsOn = "[File]$("agentDirectory" + $i)"
}
Script $("installAdoAgent" + $i)
{
GetScript = {
[bool]$adoAgentService = [bool]$(Get-Service | ? {$_.Name -like "vstsagent*$($env:COMPUTERNAME + "_agent" + $using:i)"});
return @{"Result" = $adoAgentService};
}
SetScript = {
& "$($using:configurationData.AllNodes.agentPath + $using:i)\config.cmd" --unattended --url $using:configurationData.AllNodes.adoUrl --auth PAT `
--token $using:adoPat --pool $using:configurationData.AllNodes.adoAgentPool --agent $($env:COMPUTERNAME + "_agent" + $using:i) `
--runAsService --windowsLogonAccount $using:configurationData.AllNodes.adoAgentAccount --work $($using:configurationData.AllNodes.agentPath + $using:i);
if ($LASTEXITCODE -ne 0)
{
throw "Error installing ADO agent";
}
}
TestScript = {
$adoAgentService = Get-Service | ? {$_.Name -like "vstsagent*$($env:COMPUTERNAME + "_agent" + $using:i)"};
if ($adoAgentService)
{
return $true;
}
else
{
return $false;
}
}
DependsOn = "[xArchive]$("adoAgent" + $i)"
}
}
Script installAzModules
{
GetScript = {
[bool]$azModule = [bool]$(Get-Module -ListAvailable Az);
return @{"Result" = $azModule};
}
SetScript = {
Install-Module -Name Az -Force;
}
TestScript = {
$azModule = Get-Module -ListAvailable Az;
if ($azModule)
{
return $true;
}
else
{
return $false;
}
}
}
cChocoInstaller installChocolatey
{
InstallDir = "C:\ProgramData\Chocolatey"
}
cChocoPackageInstaller visualstudio2019buildtools
{
Name = "visualstudio2019buildtools"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
cChocoPackageInstaller visualstudio2019netcorebuildtools
{
Name = "visualstudio2019-workload-netcorebuildtools"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
cChocoPackageInstaller visualstudio2019azurebuildtools
{
Name = "visualstudio2019-workload-azurebuildtools"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
cChocoPackageInstaller jmeter
{
Name = "jmeter"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
cChocoPackageInstaller azCli
{
Name = "azure-cli"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
cChocoPackageInstaller powershellCore
{
Name = "powershell-core"
AutoUpgrade = $true
Ensure = "Present"
DependsOn = "[cChocoInstaller]installChocolatey"
}
}
}