"Deploying on behalf of" and their Variables

If I have a role “database” and during the deployment I say run on octopus on behalf of, what will #{Octopus.Machine.Name} return?

The octopus machine name, or the name of the machine the Octopus Server is running on?

I essentially have a paid product on the Octopus machine that needs to run on the database server, but I have different DB servers on each environment.

I am currently including the Octopus Server as a deployment target, and pointing it to the DB via a variable, but if On behalf of works the way I think, I should be able to drop those variables in lieu of this feature.

Hi,

Thanks for reaching out!

Let’s say you have 2 machines on the Environment Dev called Database1 and Database2 that have the Database role. If you run a step from the Octopus server (not from a deployment target) on behalf of machines with the roleDatabase, that step will run once per machine with that role on the Dev environment, and on each time the variable #{Octopus.machine.name} will have the name of the machine it is running as, and not the name of the machine where the step is being executed (the Octopus server). So the first time it runs its value will be Database1 and the second time Database2

Hope that helps,
Dalmiro

Hi Dalmiro
Just as a followup. Is Octopus.Machine.Name or Octopus.Machine.HostName the proper variable to use if I am trying to get the FQDN of the machine (that is bound to the domain)

Sorry, second followup. Is there a reason why I am not allowed to deploy a package via octopus server on behalf of the Target machine

I am trying to deploy a Redgate Package via one step, rather then 2.

Is Octopus.Machine.Name or Octopus.Machine.HostName the proper variable to use if I am trying to get the FQDN of the machine (that is bound to the domain)

Octopus.Machine.Hostname does not exist as a built-in variable. There’s currently no variable to get the FQDN, but you could get it using Output variables like this:

  1. Have a powershell script step called GetMachineNames that runs on the machines (not on the Octopus servers) that you want to get the FQDN with the following code:
Set-OctopusVariable -name "FQDN" -value $env:computername
  1. Use the variable $OctopusParameters["Octopus.Action[GetMachineNames].Output.FQDN"] or #{Octopus.Action[GetMachineNames].Output.FQDN}. Every time the Octopus Server runs a step on behalf of a machine, the correct FQDN will be assigned to that variable, as long as the step GetMachineNames had previously ran on that machine.

Is there a reason why I am not allowed to deploy a package via octopus server on behalf of the Target machine

So you want to deploy package, on the Octopus Server, but on behalf of other machines to be able to use their variables? If that is the case, It really isn’t something we support as Package Deploy steps are only executed on deployment targets, and we don’t count the Octopus Server as such.

Feel free to add a sugestion to “Support Package Deploy step on Octopus Server on behalf of machines” in Uservoice if you want: https://octopusdeploy.uservoice.com/

Best regards,
Dalmiro