I’m trying to use a custom binding (I think that’s what you call it??) so that I only do the creation/update of an IIS Website for the staging environment. For production I don’t want it to change the IIS website that I already have configured (mostly due to FTP settings I have on there and also production has a heap of alternative bindings that I don’t want to have to recreate).
I have tried using each of the following custom expressions for the “Create or update an IIS Web Site and Application Pool” option:
#{Octopus.Environment.Name == "Staging"}
and also
#{if Octopus.Environment.Name == "Staging"}
I just re-read your documentation which states "You cannot use complex syntax, like #{if Octopus.Environment.Name == “Production”}, only truthy and falsy evaluations are supported. "… I kept reading that as “can”!
So now I’ve created a variable called “CreateIIS” which I set to False for production, and another set to True for staging, have changing the custom binding for the Website checkbox to “#{CreateIIS}”, and it’s working.
If there is a better way I should be doing this, please let me know.
The approach you’ve taken is the most appropriate way to toggle behaviour between environments.
That said, I would highly recommend that you keep your Staging and Production environments in sync with these kind of settings - I’ve managed to shoot myself in the foot several times with things that worked perfectly in dev and test and fail in production due to differences like this. It also helps a lot if you need to re-create your Production environment.
Very good points… I’ll take it into consideration.
I guess my main pain point, and why I have gone with not recreating IIS for now for production, is that I have to configure FTP for it (assuming there’s a set of powershell commands for that but I haven’t researched it yet), but also because I have a few alternative host names that I need setup for production. The way I do that now is to have a variable for the host name and a variable for whether it’s enabled in a given environment. See in the attached for the “www” host name? So I might need to have 3 or 4 others because of clients having extra domains (for now value whatsoever, but they felt they needed them), such as “anotherkeyword.com.au” and “yetanotherkeyword.com.au”. My variables would quickly get out of control, and also I have 8 sites that are all almost the same but for a different track, so it would be extra messy.
Is there a better way to handle having these extra bindings for particular environments? Or do I need to start looking at writing my own PowerShell scripts for these configurations? (argh!)…
It sounds like the new Tenants functionality in our (very very) soon to be released 3.4 would help a lot with deploying for multiple customers.
As for adding extra bindings, you would probably need to write some PowerShell, but it should be relatively easy, especially with the IIS PowerShell snap-in. I believe it also supports configuring FTP. You could have a comma separated list of domains and loop through it to add each binding.