Deployment to different roles with different variable scopes only executed for one of them for multiple roles on a single target machine

Hi,

in our deployment process we have a central configuration ps1 script, that needs to be run in preperation on every target node. It takes a local target directory as parameter.

We have defined roles “frontend”, “backend” and “database” in Octopus and added a variable “InstallPath”, that holds different paths scoped to the respective roles.

In the deployment process we now start the script on each node and specified the three aforementioned roles as targets. The script gets called with #{InstallPath}.

This works fine on different nodes.
However, for now our database and backend roles are located on the same machine and Octopus seems to notice, that both roles point to the same machine.
Octopus only runs the script once for this node (despite the differently scoped variable for the roles!), so it either configures the database or the backend, but not both of them.

I am aware, that I might add two different steps for this, but this seems not like an elegant solution.
Is there any way to configure this in a single step, so it is robust against changes in the role assignments?

Thanks in advance!

Hi Jan,

That’s definitely one solution.

Another solution could be to add some powershell logic that inspects the roles of the current machine and if it has more than 1 of the roles you care about, run your script once per fole. The Octopus variable that holds that information is $OctopusParameters["Octopus.Machine.Roles"] and it will contain a single string with comma separated values like "frontend, backend, database"

Let me know if that helps,
Dalmiro

Hi Dalmiro,

thanks for your reply!
For now we went along with the two step solution to get things working.

If I used a Powershell script to decide what roles are active on the tentacle as you mentioned, how would I access the different variable values for the roles? Like, is there some kind of Role/Scope->Variable Dictionary provided by Octopus in a Powershell variable like OctopusParameters?

Have a nice day,
Jan

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