Getting all tentacles instances on the deployment target

Hi! Is there any way to get all tentacles instances from the deployment target?

For example, there are 2 instances on the target, in octo they named ‘vm-dev1’ and ‘vm-dev1.local’ and they can be in different environments. I want to know that physically it s the same deployment target. Maybe it can be done from local process on the deployment target?

Kind Regards,
Alexander Yuzhanin

Hi Alexander,

We have a command in the Tentacle.exe to do just that list-instances, this will get all instances installed on that server, so you can run the below script from the script console on one of the deployment targets:

$tentacleExe = "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe"

& $tentacleExe list-instances

I hope that helps.

Thank you and kind regards,
Henrik

Hi, Henrik!
Thank you for the answer.

Not exactly, i want to know not just instance configs names on server, i want to know names of instances in octopus server. In other words, for each tentacle instance on the deployment target i want to know output of #{Octopus.Machine.Name}

Kind regards,
Alexander Yuzhanin

Hi Alexander,

We have a variable Octopus.Tentacle.Agent.InstanceName that will give you the Tentacle instance name of the deployment target you are running the script on, but you’d have to run the script on each individual target to get the Tentacle instance name to Octopus machine name correlation, so not sure if that will help you.

Other than that, there is no way to correlate instance name on deployment target and machine name in Octopus, unless you name the instances on the deployment target the same as you name the machines in Octopus.

I hope that helps.

Thank you,
Henrik

Hi, Henrik!

Ok, i understood. If it will be helpful for other customers - i wrote simple method on c# that returns all tentacles thumbprints from local machine. After that you can resolve Tentacle Names through Octopus.Api, for example:

        public List<string> GetThumbprints()
        {
            var result = new List<string>();
            var registry = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Octopus\\Tentacle");
            if (registry == null)
                return result;
            foreach (var subkey in registry.GetSubKeyNames())
            {
                try
                {
                    var configFilePath = registry.OpenSubKey(subkey)?.GetValue("ConfigurationFilePath").ToString();

                    if (configFilePath == null)
                        continue;
                    var document = XDocument.Load(configFilePath);
                    var thumbPrint = document.Root?.Elements("set").FirstOrDefault(e => e.Attribute("key")?.Value == "Tentacle.CertificateThumbprint")?.Value;
                    result.Add(thumbPrint);
                }
                catch (FileNotFoundException)
                {
                    log.Error($"Can't find config file for {subkey}");
                }
                catch (Exception e)
                {
                    log.Error(e);
                }
            }
            return result;
        }

But all of it can be simplified if octopus will store tentacle host name as a part of tentacle meta-information.

Kind regards,
Alexander Yuzhanin

Hi Alexander,

Thanks for sending through the script.

Thanks,
Henrik

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.