Variable value per Tenant+Environment+Target?


I have 16 web servers and 8 standalone database servers with same content (to spread the load).
Each web server contains the same site deployed for 16 tenants.

I have 2 tasks to do but they seem to be similar in what is needed.

I have a variable called ‘DatabaseServer’ which should point to the correct host.
How can I set this variable value to be different for the combination of tenant/environment/target?
We have a situation that a tenant is deployed to multiple web servers but these different web servers (for this tenant) need to connect to a different database server to spread the load.

We also have a load-balancing scenario where I need a variable to mark which tenant on a specific web server in PROD is attached or detached from the load-balancer. So I also need to set this value per tenant/environment/target.

How can I achieve my goal?

Thanks for your help.

Hi @Mat

Thanks for sharing your architecture with me, hopefully I can give you some ideas to work with.

To clarify, how are you currently taking advantage of tenants, are you using tenants for different customer configurations?

Generally speaking, the starting point for this kind of scoping is using tenant specific variables however it sounds like you want to go further and scope to the machine, which is not a ‘first class’ scenario at the moment.

If there is some naming conventions you can lean on, you could use some variable expressions along with tenant specific variables, something like this for instance:

Above, I’ve leaned on the fact that standard project variables can be scoped down to the machine, and then substituted data from tenant specific variables.

This syntax can use conditionals too.

I’m not sure if this solves your first task very well though - apologies if that is the case.

For your second task, is your intent is to leave behind some state about load balancer status for subsequent deployments to read in? Why do you need to know the tenant name later?

Again nothing first class comes to mind, but some scenarios I’ve seen out there include:

  • Use the load balancer products own API or scripts/commandlets to give you data about which node is connected.
  • Use of marker files (like a .active-node file) that are read at deployment time to determine the connected node

You could go as far as updating a project variable with a complex structure (JSON?) using some Octopus Client calls from a script step, it depends a bit on what you are looking to do with this ‘marker’.

Hope this helps,

Hi Jim,

I found that the easiest solution was to create a new tenant tag set and define a separate tag for each tenant. Then i would be able to scope the variable to environment+target+tenant tag and each tag is assigned to just one tenant.

It looks like I achieved what I needed.

Thanks for your help.

Thanks @Mat

Glad to read that tenant tags work for your scenario!

All the best,


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