Skip to content

Commit

Permalink
Improve doco around azure with bicep scripts. (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeButters authored Dec 11, 2023
1 parent 1d5361a commit 8fa00ba
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
33 changes: 21 additions & 12 deletions testing/compatibility/azure/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,76 +10,85 @@ $env:adminPassword = $adminPassword

$env:octopusServerRole = 'OsTestingListening'
$env:octopusServerEnvironment = 'OsTesting'
$env:tentacleVersion = '7.0.201'
$env:tentacleVersion = '8.1.32'

## Takes this on to the end of the tentacle's name as seen in octopus
$env:tentacleNamePostfix = "$env:tentacleVersion"

az group create --name Tentacle --location australiaeast
$group = 'TentacleOldTimeout'
$resourcegroup = $group

az group create --name $group --location australiaeast

# .NET 6.0
#---------------------------------
$env:tentacleUri = "https://octopus-downloads-staging.s3.amazonaws.com/octopus/Octopus.Tentacle.$env:tentacleVersion-net6.0-win-x64.msi"
$netFramworkVersion = 'net6'

# Windows 2012
$env:virtualMachineName = 'Net6Tentacle-Window2012'
$env:virtualMachineSku = '2012-datacenter-gensecond'
$env:os = 'windows2012'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2012R2
$env:virtualMachineName = 'Net6Tentacle-Window2012R2'
$env:virtualMachineSku = '2012-r2-datacenter-gensecond'
$env:os = 'windows2012R2'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2016
$env:virtualMachineName = 'Net6Tentacle-Window2016'
$env:virtualMachineSku = '2016-datacenter-gensecond'
$env:os = 'windows2016'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2019
$env:virtualMachineName = 'Net6Tentacle-Window2019'
$env:virtualMachineSku = '2019-datacenter-gensecond'
$env:os = 'windows2019'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2022
$env:virtualMachineName = 'Net6Tentacle-Window2022'
$env:virtualMachineSku = '2022-datacenter-azure-edition'
$env:os = 'windows2022'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam


# .NET 4.8
#---------------------------------
$env:tentacleUri = "https://octopus-downloads-staging.s3.amazonaws.com/octopus/Octopus.Tentacle.$env:tentacleVersion-x64.msi"
$netFramworkVersion = 'net48'

# Windows 2012
$env:virtualMachineName = 'Net48Tentacle-Window2012'
$env:virtualMachineSku = '2012-datacenter-gensecond'
$env:os = 'windows2012-48'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2012R2
$env:virtualMachineName = 'Net48Tentacle-Window2012R2'
$env:virtualMachineSku = '2012-r2-datacenter-gensecond'
$env:os = 'windows2012R2-48'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2016
$env:virtualMachineName = 'Net48Tentacle-Window2016'
$env:virtualMachineSku = '2016-datacenter-gensecond'
$env:os = 'windows2016-48'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2019
$env:virtualMachineName = 'Net48Tentacle-Window2019'
$env:virtualMachineSku = '2019-datacenter-gensecond'
$env:os = 'windows2019-48'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

# Windows 2022
$env:virtualMachineName = 'Net48Tentacle-Window2022'
$env:virtualMachineSku = '2022-datacenter-azure-edition'
$env:os = 'windows2022-48'
az deployment group create --name Tentacle --resource-group Tentacle --template-file vm.bicep --parameters vm.bicepparam
az deployment group create --name $group --resource-group $resourcegroup --template-file vm.bicep --parameters vm.bicepparam

echo "Net48 tentacles will not connect, restart all net48 VMs then re-run the script in c:\\TentacleInstallRun.ps1 OR after restart modify the install-tentacle.ps1 script (add an extra Write-Host) so bicep see's it as a differnt script and so will re-run the script on the VMs again."
22 changes: 15 additions & 7 deletions testing/compatibility/azure/install-tentacle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ $octopusServerApiKey,
$octopusServerRole,
$octopusServerEnvironment,
$os,
$tentacleUri)
$tentacleUri,
$tentacleNamePostfix)

# Record the arguments this script was called with, so that it is easy to run later.
myargs = "$octopusServerThumbprint $octopusServerUrl $octopusServerApiKey $octopusServerRole $octopusServerEnvironment $os $tentacleUri $tentacleNamePostfix"
$altCmd = "$PSCommandPath $myargs"
$altCmd > c:\\TentacleInstallRun.ps1

[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Expand All @@ -21,19 +27,20 @@ if ($installedVersion -lt $net48BuildNumber) {
$process = start-process "C:\Windows\Temp\ndp48-x86-x64-allos-enu.exe" -argumentlist @("/q", "/norestart", "/log", "C:\Windows\Temp\ndp48-x86-x64-allos-enu.log") -wait -PassThru
$process.WaitForExit()
Write-Host "Installed .NET 4.8"
# For net48 to work the machine must be rebooted, and this script re-run.
} else {
Write-Host "Net framework 4.8 already installed"
}





$tentacleMsiFilename = "tentacle.msi"

Write-Host "Downloading Tentacle installer from $tentacleUri"
(New-Object System.Net.WebClient).DownloadFile($tentacleUri, $tentacleMsiFilename)

# Set environment variables here e.g.:
# [System.Environment]::SetEnvironmentVariable('TentacleTcpKeepAliveEnabled','true', 'Machine')

Write-Host "Installing Tentacle"
$result = start-process "msiexec" -ArgumentList @("/a", $tentacleMsiFilename, "/qn") -wait -passthru
if ($result.ExitCode -ne 0)
Expand All @@ -58,7 +65,7 @@ $ip = Invoke-RestMethod http://ipinfo.io/json
& $tentacleExe configure --instance "TentacleListening" --home "C:\Octopus\TentacleListening" --app "C:\Octopus\TentacleListening\Applications" --port "10933" --console
& $tentacleExe configure --instance "TentacleListening" --trust $octopusServerThumbprint --console
&"netsh" advfirewall firewall add rule "name=Octopus Deploy Tentacle" dir=in action=allow protocol=TCP localport=10933
& $tentacleExe register-with --instance "TentacleListening" --server $octopusServerUrl --name "listening-$os" --apiKey=$octopusServerApiKey --role $octopusServerRole --environment $octopusServerEnvironment --comms-style TentaclePassive --publicHostName $ip.Ip --console
& $tentacleExe register-with --instance "TentacleListening" --server $octopusServerUrl --name "listening-$os-$tentacleNamePostfix" --apiKey=$octopusServerApiKey --role $octopusServerRole --environment $octopusServerEnvironment --comms-style TentaclePassive --publicHostName $ip.Ip --console
& $tentacleExe service --instance "TentacleListening" --install --start --console

Write-Host "----------------------------"
Expand All @@ -71,5 +78,6 @@ Write-Host "----------------------------"
& $tentacleExe new-certificate --instance "TentaclePolling" --if-blank --console
& $tentacleExe configure --instance "TentaclePolling" --reset-trust --console
& $tentacleExe configure --instance "TentaclePolling" --home "C:\Octopus\TentaclePolling" --app "C:\Octopus\TentaclePolling\Applications" --noListen "True" --console
& $tentacleExe register-with --instance "TentaclePolling" --server $octopusServerUrl --name "polling-$os" --apiKey=$octopusServerApiKey --role $octopusServerRole --environment $octopusServerEnvironment --comms-style TentacleActive --server-comms-port "10943" --force --console
& $tentacleExe service --instance "TentaclePolling" --install --start --console
& $tentacleExe register-with --instance "TentaclePolling" --server $octopusServerUrl --name "polling-$os-$tentacleNamePostfix" --apiKey=$octopusServerApiKey --role $octopusServerRole --environment $octopusServerEnvironment --comms-style TentacleActive --server-comms-port "10943" --force --console
& $tentacleExe service --instance "TentaclePolling" --install --start --console

3 changes: 2 additions & 1 deletion testing/compatibility/azure/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ Ensure the variables in `deploy.ps1` are correct. Some variables of note:

### Deploy
Now, install the VMs and install Tentacle:
> ./deploy.ps1 -octopusServerThumbprint {OctopusServerThumbprint} -octopusServerUrl {OctopusServerUri} -octopusServerApiKey {OctopusServerApiKey} -adminPassword qwerty123!@#
> ./deploy.ps1 -octopusServerThumbprint {OctopusServerThumbprint} -octopusServerUrl {OctopusServerUri} -octopusServerApiKey {OctopusServerApiKey} -adminPassword {superSecretPasswordToTheVms.2}
Where:
- OctopusServerUri - The URI of the instance you wish to register against. E.g. https://sast-rpc-retires.testoctopus.app
- OctopusServerThumbprint - The thumbprint from the same Octopus Server (found in Settings => Thumbprint)
- OctopusServerApiKey - The API key to use from the same Octopus Server (create via your profile on the Octopus Server instance)
- adminPassword - The admin password to use for the created VMs, don't forget to write it down if you need access to the VMs.

This script will take a while.

Expand Down
7 changes: 6 additions & 1 deletion testing/compatibility/azure/vm.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ param octopusServerRole string
param octopusServerEnvironment string
param os string
param tentacleUri string
param tentacleNamePostfix string

var networkSecurityGroupName = '${virtualMachineName}-nsg'
var networkInterfaceName = '${virtualMachineName}-nic'
Expand Down Expand Up @@ -125,7 +126,7 @@ resource virtualMachine 'Microsoft.Compute/virtualMachines@2022-03-01' = {
location: location
properties: {
hardwareProfile: {
vmSize: 'Standard_B2als_v2'
vmSize: 'Standard_DS1_v2'
}
storageProfile: {
osDisk: {
Expand Down Expand Up @@ -206,6 +207,10 @@ resource deploymentscript 'Microsoft.Compute/virtualMachines/runCommands@2022-03
name: 'tentacleUri'
value: tentacleUri
}
{
name: 'tentacleNamePostfix'
value: tentacleNamePostfix
}
]
protectedParameters: [
{
Expand Down
1 change: 1 addition & 0 deletions testing/compatibility/azure/vm.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ param octopusServerRole = readEnvironmentVariable('octopusServerRole', '')
param octopusServerEnvironment = readEnvironmentVariable('octopusServerEnvironment', '')
param os = readEnvironmentVariable('os', '')
param tentacleUri = readEnvironmentVariable('tentacleUri', '')
param tentacleNamePostfix = readEnvironmentVariable('tentacleNamePostfix', '')

0 comments on commit 8fa00ba

Please sign in to comment.