-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall-Tentacle.ps1
95 lines (77 loc) · 3.28 KB
/
Install-Tentacle.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
<#
.SYNOPSIS
Install and configure a tentacle
.PARAMETER APIKey
The Octopus APIKey
.PARAMETER Thumbprint
The Octopus machine thumbprint
.PARAMETER TentacleVersion
Version of the tentacle to install, defaults to 3.23.2-x64
.PARAMETER OutpusUrl
Url of your octopus server
#>
param(
[Parameter(Mandatory)]
[string] $APIKey,
[Parameter(Mandatory)]
[string] $Thumbprint,
[Parameter(Mandatory)]
[string[]] $Roles,
[Parameter(Mandatory)]
[string[]] $Environments,
[Parameter(Mandatory)]
[string] $PublicDnsName,
[Parameter(Mandatory)]
[string] $DisplayName,
[string] $TentacleVersion = "3.23.2-x64",
[string] $OctopusUrl = "https://clearmeasure.octopus.com"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# not getting it split into array somewhere along the way.
if ( $Environments.Count -eq 1 )
{
$Environments = $Environments[0] -split ","
}
if ( $Roles.Count -eq 1 )
{
$Roles = $Roles[0] -split ","
}
Logit "Install-Tentacle started"
Logit -indent "APIKey $($APIKey[0]+"*"*$APIKey.Length)"
Logit -indent "Thumbprint $($Thumbprint[0]+"*"*$Thumbprint.Length)"
Logit -indent "OctopusUrl is $OctopusUrl"
Logit -indent "TentacleVersion is $TentacleVersion"
Logit -indent "Role is $Roles"
Logit -indent "Environment is $Environments"
Logit -indent "Public DNS Name is $PublicDnsName"
Logit -indent "Display Name is $DisplayName"
$fname = "Octopus.Tentacle.$TentacleVersion.msi"
Invoke-WebRequest "https://download.octopusdeploy.com/octopus/$fname" -OutFile $fname
Logit -indent "Downloaded $fname"
msiexec.exe /i $fname /quiet | out-null
Logit -indent "Tentacle Installer exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
Push-Location "C:\Program Files\Octopus Deploy\Tentacle"
$ErrorActionPreference = "Stop"
try
{
.\Tentacle.exe create-instance --instance "Tentacle" --config "C:\Octopus\Tentacle.config" --console | Out-null
Logit -indent "create instance exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
.\Tentacle.exe new-certificate --instance "Tentacle" --if-blank --console | Out-null
Logit -indent "new-certificate exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
.\Tentacle.exe configure --instance "Tentacle" --reset-trust --console | Out-null
.\Tentacle.exe configure --instance "Tentacle" --home "C:\Octopus" --app "C:\Octopus\Applications" --port "10933" --console | Out-null
.\Tentacle.exe configure --instance "Tentacle" --trust $Thumbprint --console | Out-null
Logit -indent "config commands exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
netsh.exe advfirewall firewall add rule "name=Octopus Deploy Tentacle" dir=in action=allow protocol=TCP localport=10933 | Out-null
Logit -indent "netsh exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
$cmd = ".\Tentacle.exe register-with --instance 'Tentacle' --name '$DisplayName' --server $OctopusUrl --apiKey=$ApiKey --role $($Roles -join ' --role ') --environment $($Environments -join ' --environment ') --comms-style TentaclePassive --console --publichostname $PublicDnsName -force | Out-null"
Invoke-Expression $cmd
Logit -indent "register with exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
.\Tentacle.exe service --instance "Tentacle" --install --start --console | Out-null
Logit -indent "service exited with $LASTEXITCODE" -lastexit $LASTEXITCODE
}
finally
{
Pop-Location
}