Config transformation that takes server tag in consideration

Hi!

We have an environment with multiple production servers. Each needs a separate config transformation. Is there any way to make Octopus Deploy use a config transformation based on both environment and tag? Ex: Web.Production.Server1.config (where Production is environment and Server1 is tag).

Regards,
Bjørn Terje Svennes

Hi Bjorn,

Thanks for the reply. Sorry about the delay in getting back to you.
Where is tag coming from? Is it set as a project variable? You could add your additional transform such as:
web.#{Octopus.Environment.Name}.#{MyOctopusVar}.config => web.config

Otherwise if you could explain where tag is coming from I can try to help.

Vanessa

After checking I see that what I call “tag” is actually “role”. So the question is really if it is possible to use the “role” as part if the config-name?

Hi Bjorn,

‘Not really’ is the answer. Steps, deployments etc can have multiple roles, so the variables related to roles are treated as such. There is no one variable that would define a specific role for you. I mean you could use one but if anyone ever adds more than one role to your deployment it would break. You could just add it as a project variable such as #{MyRole} and scope it to that role. This might actually be the safest option.

Otherwise if you want to take your chances and play with the variable, Octopus.Action.TargetRoles is what exists, but it is a list.

Vanessa

Thank you for your reply.

I understand that using roles may not be such a good idea. Still I need the environment to control this aspect because my project has no way of knowing which server it is intended for. Is there any other way I can set up the servers under “Environments” so that they will use two different config files? I have the same situation for some files that are intended for specific production servers.

Hi Bjorn,

With Lifecycles you can deploy to more than 1 environment at once. Could you set them as their own environments, and deploy to both at once? ie Environment-role
Machines can also have multiple environments. If this doesn’t sound feasible, could you explain a bit more about your situation and deployment needs?

Vanessa

Thank you for taking your time to answer my questions.

Lifecycles would solve the problem, but it seems that a lifecycle is defined for the whole Octopus Deploy Server? Would it be possible to define it for just my project? I don’t want to mess up things for others using the Octopus Deploy Server (we have a lot of projects).

I can explain a bit more about what type of environment we have:
There are two production server behind a load balancer. One can be seen as a primary server and in addition to the site itself it also has various resources (images). The secondary server only hosts a copy of the site and references the resources on the primary server. The location of the resources is set up in configuration files. For the primary server it points to a directory on the server itself. On the secondary it points to a share on the primary server. So when deploying the primary server I need to use one specific set of configuration files and another set when deploying to the secondary server. In addition a license file is provided. This is different from each server (bound to the MAC-address). So when deploying to the primary server licensefile1 is to be copied and when deploying to the secondary server licensefile2 is top be copied (in reality the license file has the same name, but is located in separate directories).

Hope this clarifies my deployment needs :slight_smile:

Hi Bjorn,

Each project can set what Lifecycle it uses. So if you create your own it won’t effect any other project in your Octopus Server instance.
So you could have two environments in this case such as ProductionPrimary and ProductionSecondary and have them both deployed to in a single Production phase in your Lifecycle.
Thus allowing you to deploy to both at once, and have their own config settings based on environments.

Vanessa