Hi,
I’m using the following script to install a Tentacle on a new server using Chocolatey. This works very well with one problem: at the octopus server the tentacle url is set to :. This doens’t work for me, it should be :. Can this be done? Is there a switch statement that I can use?
$arguments = @{}
Let’s assume that the input string is something like this, and we will use a Regular Expression to parse the values
/Port:81 /Edition:LicenseKey /AdditionalTools
Now we can use the $env:chocolateyPackageParameters inside the Chocolatey package
$packageParameters = $env:chocolateyPackageParameters
Write-Host $packageParameters
Default the values
$port = “10933”
Now parse the packageParameters using good old regular expression
if ($packageParameters) {
$match_pattern = “/(?([a-zA-Z]+)):(?(["'])?([a-zA-Z0-9- _\\:\.]+)([
”’])?)|/(?([a-zA-Z]+))"
$option_name = ‘option’
$value_name = ‘value’
if ($packageParameters -match $match_pattern ){
$results = $packageParameters | Select-String $match_pattern -AllMatches
$results.matches | % {
$arguments.Add(
$_.Groups[$option_name].Value.Trim(),
$_.Groups[$value_name].Value.Trim())
}
}
else
{
Throw "Package Parameters were found but were invalid (REGEX Failure)"
}
if ($arguments.ContainsKey("Port")) {
Write-Host "Port Argument Found"
$port = $arguments["Port"]
}
} else {
Write-Debug “No Package Parameters Passed in”
}
$silentArgs = “/S /Port:” + $port
Write-Debug “This would be the Chocolatey Silent Arguments: $silentArgs”
Install-ChocolateyPackage -PackageName 'octopustentacle'
-FileType ‘msi’ -SilentArgs '/quiet'
-Url ‘https://download.octopusdeploy.com/octopus/Octopus.Tentacle.3.4.14.msi’ -Url64bit 'https://download.octopusdeploy.com/octopus/Octopus.Tentacle.3.4.14-x64.msi'
-Checksum ‘ED95CB194A124C7BD5D67978EDCE722C139A4F80A0B46D6531923B112D032F77’ -ChecksumType 'SHA256'
-Checksum64 ‘7A468F71B18E099BB3CCC81D603CC3225114D67F516D397F8A61EB03DBCEEE55’ `
-ChecksumType64 ‘SHA256’
cd “C:\Program Files\Octopus Deploy\Tentacle”
& .\Tentacle.exe create-instance --instance “Tentacle” --config “C:\Octopus\Tentacle.config” --console
& .\Tentacle.exe new-certificate --instance “Tentacle” --if-blank --console
& .\Tentacle.exe configure --instance “Tentacle” --reset-trust --console
& .\Tentacle.exe configure --instance “Tentacle” --home “C:\Octopus” --app “C:\Octopus\Applications” --port “10933” --console
& .\Tentacle.exe configure --instance “Tentacle” --trust “” --console
netsh advfirewall firewall add rule “name=Octopus Deploy Tentacle” dir=in action=allow protocol=TCP localport=10933
& .\Tentacle.exe register-with --instance “Tentacle” --server “http://xxxxxx.westeurope.cloudapp.azure.com” --apiKey="" --role “web-server” --environment “Test” --comms-style TentaclePassive --console
& .\Tentacle.exe service --instance “Tentacle” --install --start --console
Kind regards,
Erwin