Once a tentacle instance is created the communication mode (listening or polling) cannot be changed. What you will need to do is create a new instance. This is one use case where the new Runbooks feature comes in handy.
Please note: This assumes you moved your Octopus Deploy instance to Azure already.
You will have two runbooks. The first runbook will:
- Use the run a script step on the existing tentacle to create a new polling tentacle instance.
The second runbook will:
- Use the run a script step on the new polling tentacle to disable the registration for the older listening tentacles.
- Pause for manual intervention while you test some deployments to the new tentacle instances.
- Use the run a script step on the new polling tentacle to delete the older listening tentacle instances.
First, let's use the script console to create polling tentacles. A couple of notes:
- When you register the new tentacles with Octopus Deploy, you will need to supply a name. I suggest you use something easy to remember. If your current listening tentacles are registered as [MachineName], then use [MachineName]-Polling.
- In addition to providing your deployment roles, also add "PollingTentacle" as a role that will make it easy for future runs with the script console.
$OldMachineName = $OctopusParameters["Octopus.Machine.Name"]
$Environment = $OctopusParameters["Octopus.Environment.Name"]
$Roles = $OctopusParameters["Octopus.Machine.Roles"]
$APIKey = #Your API Key
$Server = #Your Server
$NewMachineName = "$OldMachineName-Polling"
Set-Location "C:\Program Files\Octopus Deploy\Tentacle"
$baseArgs = @("register-with","--instance=Polling","--Name=$NewMachineName","--server=$Server","--apiKey=$octopusApiKey","--comms-style=TentacleActive","--server-comms-port=10943","--environment=$Environment")
$roleList = $roles -split ","
foreach ($role in $roleList) {
$baseArgs += "--role=$role"
}
$baseArgs += "--console"
& .\Tentacle.exe create-instance --instance "Polling" --config "C:\Octopus\Tentacle.config" --console
& .\Tentacle.exe new-certificate --instance "Polling" --if-blank --console
& .\Tentacle.exe configure --instance "Polling" --reset-trust --console
& .\Tentacle.exe configure --instance "Polling" --home "C:\Octopus\Polling" --app "C:\Octopus\Applications\Polling" --noListen "True" --console
& .\Tentacle.exe $baseArgs
& .\Tentacle.exe service --instance "Polling" --install --start --console
Next, using the API, disable the older machines. This is where having the role "PollingTentacles" and the machine registration set to [MachineName]-Polling makes it easy. This script will disable the older target.
###CONFIG###
$OctopusURL = #Octopus Server root URL
$APIKey = #Octopus API Key
$NewMachineName = $OctopusParameters["Octopus.Machine.Name"]
$machineName = $NewMachineName -replace "-Polling", ""
###PROCESS###
$header = @{ "X-Octopus-ApiKey" = $APIKey }
#Getting all machines
$allmachines = Invoke-RestMethod $OctopusURL/api/machines/all -Headers $header
#Filtering machine by name
$machine = $allmachines | ?{$_.name -eq $machineName}
#Setting the "IsDisabled" property
$machine.IsDisabled = $true #Set to $false to disable the machine
#Converting $machine into a JSON blob to PUT is back to the server
$body = $machine | ConvertTo-Json -Depth 4
#Pushing the modified machine to the userver
Invoke-RestMethod ($OctopusURL + $machine.Links.Self) -Method Put -Body $body -Headers $header
Now that the polling tentacles are running and the older tentacles as disabled, run some test deployments. Everything should continue to work as-is.
Finally, you will need to leverage the script console to deregister and delete the old tentacle.
cd "C:\Program Files\Octopus Deploy\Tentacle"
Tentacle.exe deregister-from --instance "Tentacle" --server "http://YOUR_OCTOPUS" --apiKey "API-YOUR_API_KEY" --multiple
Tentacle.exe delete-instance --instance "Tentacle"
For more information about the command line, please refer to our documentation.
If this puts you over your license limits, please reach out to support@octopus.com, explain what you are trying to do, and we will provide you with a temporary license.