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)