I’m wondering how the best way of going about installing multiple service instances on the one machine might be. I want to perform 3 steps for each service:
- Stop Service
- Extract service package
- Start Service
We have over 25 services, all the same executable files but different names and different config settings (log directories etc.).
That log respectively to:
I would like to create something like a looped step (like a rolling deployment container step) that can loop through all of the services we have (which would be variables) and adjust the “A”, “B”, “C” in the above values with actual names that are variables for the Project. I want to avoid, if possible, having the above 3 deployment steps (stop, copy, start) duplicated for EACH of the 25+ services.
This also needs to be done on multiple environments and target machines (ie; UAT A1, UAT A2, UAT B1, UAT B2, PROD A1, PROD A2 etc.). But this is taken care of by different environments set up in Octopus.
What’s the best way to do this? Is it better to just do all of this in a powershell script or similar (I’d rather not, I’d like to use the Octopus Step Templates if possible)? Could Tenants be the best option for setting this up (as in a “Tenant” for each service)?
To add to this I’m wondering if I had variables all targeted at the same machines whether it would automatically loop through.
So “A”, “B”, “C”, etc. were set to machine UAT A1, UAT A2, UAT B1, UAT B2, PROD A1, PROD A2 etc. whether it would target each machine with ALL of the service names (so have the list of 25+ variables targeting all machines).
Is that how this can work? I wasn’t sure whether the scoping of the variable for the same level of targeted machine would perform an all inclusive install, or whether it would pick the very first variable / machine combo and ignore the rest?
Thanks for getting in touch. Great question! There are a few ways you could accomplish this (step templates, custom scripts etc) but I think that using multi-tenant deployments would be the simplest and would avoid writing custom scripts. This keeps things simple and takes care of all the looping for you.
Our multi-tenant deployment guide is the best place to get started and I’d highly recommend giving it a review.
That said, I would do something like the following.
- Turn on the multi-tenant deployment feature one the Configuration -> Features page.
- Create a project and add a windows service step or a package step with the windows service feature turned on. Our built-in step is heavily used so you’re getting a rock solid solution rather than writing it yourself.
- Add your first tenant and connect it to the project and the appropriate environments. In this structure, each tenant would be a service.
- Add variable templates for all the configuration parameters that change per tenant/service. I’d highly recommend reviewing our documentation page on working with tenant-specific variables as it explains the options available.
- Add additional tenants for each service.
- If desired, create tenant tag sets to group and organise your tenants. This helps greatly at deployment time as you it simplifies tenant selection.
I’d suggest starting with a structure like this and tweak it as it suits your team. I believe that should answer your questions but let me know if anything is unclear.
Hope this helps!
Thanks for this information. This is what I’ve decided to do. I’ve made the Project “Tenant capable” and made a tenant for each service (eg; Tenant A with a variable value as “A”).
I’ve also used tenant tagging for the steps to make things easier.
I haven’t yet done a prototype deployment so I’m not sure how this will work (as still setting up the deployment process in Octopus) but it looks alright. One thing has me concerned and that’s on the Project Overview page it lists all of the Tenants against all of the Environments (with a deploy button for each Tenant’s Environment).
I guess I’m concerned because I hope I can deploy to all Tenants in one Environment in one step (as in I don’t need to click Deploy 25+ times for each environment. I’ll find out that when I come to actually doing the step but if anyone could give a heads up whether or not I can click or setup something that will result in “Deploy to UAT A1 / UAT A2 for ALL Tenants” that’d be great. Thanks for the response!
Thanks for the reply. In regards to your question, you can click the deploy button on the project overview dashboard to deploy to individual tenants or you can deploy a release and select the tenants from there. One of the easiest ways to manage tenant selection is using tags/tag sets. Because they’re generic, you could create a tag set and tags that groups tenants for deployment as you need. Our Designing a multi-tenant hosting model documentation page provides one example on how to do this.
Hope this helps!