Skip to content

Instantly share code, notes, and snippets.

@hnrkndrssn
Last active August 7, 2017 04:19
Show Gist options
  • Save hnrkndrssn/b0c3152cda9de3bb0f96 to your computer and use it in GitHub Desktop.
Save hnrkndrssn/b0c3152cda9de3bb0f96 to your computer and use it in GitHub Desktop.
Register a Polling Tentacle without opening up port 443 to the world
# Step 1 - Run this on the Tentacle server to create the new Tentacle
$tentacleName = 'P1'
$tentaclePort = 10933
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" create-instance --instance $tentacleName --config "C:\Octopus\$tentacleName\Tentacle-$tentacleName.config"
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" new-certificate --instance $tentacleName --if-blank
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance $tentacleName --reset-trust
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance $tentacleName --home "C:\Octopus\$tentacleName" --app "C:\Octopus\Applications\$tentacleName" --port $tentaclePort --noListen "True"
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" service --instance $tentacleName --install --start
# Step 2 - Run this on your Octopus Server
Add-Type -Path 'C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll'
$apikey = 'API-XXXXXXXXXXXXXXXXXXXXXXXXX' # Get this from your profile
$octopusURI = 'http://octopus.url' # Your Octopus Server address
$tentacleThumbprint = "" # Your Tentacle thumbprint
$environmentId = "Environments-1" # Get this from /api/environments
$role = "tentacle-role" # The role of the machine
$machineName = "YourTentacleName" # The name of the machine
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$tentacleEndpoint = New-Object Octopus.Client.Model.Endpoints.PollingTentacleEndpointResource
$tentacleEndpoint.Thumbprint = $tentacleThumbprint
$tentacleEndpoint.Uri = "poll://" + (([char[]]([char]'A'..[char]'Z') | sort {get-random})[0..20] -Join '') + "/"
$tentacle = New-Object Octopus.Client.Model.MachineResource
$tentacle.Endpoint = $tentacleEndpoint
$tentacle.EnvironmentIds.Add($environmentId)
$tentacle.Roles.Add($role)
$tentacle.Name = $machineName
$repository.Machines.Create($tentacle)
Write-Host "Add this value to the 'Tentacle.Communication.TrustedOctopusServers' key in Tentacle-${machineName}.config"
$server = [ordered]@{
"Thumbprint" = ""; # Your Octopus Server Thumbprint
"CommunicationStyle" = 2;
"Address" = "https://octopus.url:10943"; # Your Octopus Server URL and Communications port (10943 by default)
"Squid" = "";
"SubscriptionId" = $tentacleEndpoint.Uri;
}
$server | ConvertTo-Json -Compress
  • Open the Tentacle configuration file of your new Tentacle (specified when you registered the Tentacle in step 1)
    • Add the JSON output by step 2 above to the Tentacle.Communication.TrustedOctopusServers (within the [])
    • Save the config file
    • Restart the Tentacle service
  • Perform a health check and if everything is right, the new polling Tentacle should report back successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment