0

I need to run a console app after deployment, but the tool should only be run once per environment. I have two roles defined per environment, DatabaseServer and AppServer. The tool should be run on the AppServer machine.

I deploy the console app using a nuget package and a custom PowerShell script to copy it to the correct location on the AppServer machine.

Everything is fine when there is only one machine in the AppServer role, but I cannot think of an elegant way of ensuring the tool is run exactly once when there is more than one machine in the AppServer role.

The only way I can think of is if I specify a variable per environment that contains the name of the machine that the tool should run on. In the PowerShell script I could check this value and if it's not equal to the current machine name, just exit the script successfully. This doesn't feel right though - it needs a variable per environment, and if the machines in the AppServer change (and the one the app should run on is removed) then the deployment will be classed as successful but the tool will not have run.

Is there anything simple that I've overlooked? Or will I have to make do with this approach? (which makes me sad)

1 Answers1

0

You could give the AppServer machine that will run this tool a second role such as ToolRunner, for example. You could then create a deployment process step that targets the ToolRunner role and executes the console application on the one and only machine that has happens to be defined with that role.

This would require no change to your PowerShell scripts or to Octopus variables. However, should you remove the machine that is tagged with the ToolRunner tag from the environment, you would have to make sure to assign the tag to a new machine for your process to continue to work as you wish it to.

Codatrix
  • 126
  • 4