Programmatically determine if tentacle is registered

I’m working on the chef cookbook to automate the installation of tentacles.

How could you programmatically determine if the node is already registered with the Octopus deploy server?
The goal is to make the register resource idempotent so that it only registers the tentacle once.
Preferably there would be a way to use Tentacle.exe from the node itself, or query a registry setting or config value.

Hi Sowen,

Thanks for getting in touch!

You could use our Octopus.Client NuGet package to query the machines that are currently registered with your Octopus Server to determine if the machine has already been registered.

Hope that helps!

Thank you and warm regards,
Henrik

Thanks, here is the powershell script that I was able to get working.

It returns True if the thumbprint already exists on the Octopus Deploy server, False if it is absent

Up to date version of script stored here:

# Powershell script to see if an octopus deploy tentacle is registered with an octopus deploy server
# Returns true if node is 'not' registered
# Replace 'http://octopus.example.com' and '1234578910' with your server and octopus deploy api key
Add-Type -Path '.\\Newtonsoft.Json.dll'
Add-Type -Path '.\\Octopus.Client.dll'
$endpoint = new-object Octopus.Client.OctopusServerEndpoint 'http://octopus.example.com', '12345678910'
$repository = new-object Octopus.Client.OctopusRepository $endpoint
$tentacle = New-Object Octopus.Client.Model.MachineResource
$thumbprint = (& '.\\Tentacle.exe' show-thumbprint --nologo --console)
$thumbprint = $thumbprint -replace '.*([A-Z0-9]{40}).*', '$1'
[string]::IsNullOrEmpty($thumbprint) -OR $repository.Machines.FindByThumbprint($thumbprint).Thumbprint -ne $thumbprint

Hi Sowen,

Great to hear that you got it working, and thanks for sending through the resulting script. We can then refer to that if we get other customers asking the same question.

Thank you and best regards,
Henrik

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.