Options

Multi-tenant deployments with ReadyRoll and Octopus

dnlnlndnlnln Posts: 234 Gold 2
edited August 4, 2016 12:40AM in ReadyRoll
Posted with permission of customer to benefit the community:

Our setup has multiple databases per environment, and in each environment there could be multiple databases on the same server (potentially up to 20 databases on the same server).

For example:

TEST

Server A
DB_Test1
DB_Test2

Server B
DB_Test3

PRODUCTION

Server C
DB_Prod1
DB_Prod2

Server D
DB_Prod3
DB_Prod4
DB_Prod5
DB_Prod6

Ideally, I’d like to have one Octopus Deploy tentacle per database server, and then be able to deploy to every database on that server for the current environment using the ReadyRoll NuGet package that we deployed to Octopus Deploy. However, everything I've seen thus far would require me to either a) add a tentacle for every database, which could lead to upwards of 20 tentacles on the same server, or b) create a step for each database to deploy to, which leads to a ton of steps.

I should be able to utilize the new Multi-Tenancy functionality from Octopus Deploy 3.4 to handle this, however while that should work (hopefully), I’m wondering if you have any other ideas as to how to handle this scenario?
Daniel Nolan
Product Manager
Redgate Software

Comments

  • Options
    There might be a way to achieve this without resorting to adding a multitude of tentacles/steps, and without needing version 3.4 of Octopus.

    In order to deploy your package to multiple databases, you could customize the "Deploy.ps1" script that ReadyRoll produces at build-time with logic applicable to your use case. For example, within the Deploy.ps1 script you’ll find a single call to SqlCmd.exe. If you were to add a variable in Octopus that contains a comma-separated list of database names, you could loop over this variable within the script to call SqlCmd for as many items in the list (note that, as the user transactions are per-database, if one of the database deployments happens to fail, only that failed db will be rolled-back to the previous state). This way, you only need to configure one step in Octopus for each package.

    In order to include your customized deployment script in your Octopus nuget package, simply add the Deploy.ps1 file to the root of your ReadyRoll database project; during build, your custom script will be used in place of the automatically-generated script.

    I hope this makes sense. Please let me know if you have any questions.
    Daniel Nolan
    Product Manager
    Redgate Software
  • Options
    Response from customer:

    That is a fantastic solution, and I’m looking forward to trying it out. Hopefully we can do that so we don’t have to wait until Octopus 3.4 is live and stable before we get started. If I run into any issues I will let you know.
    Daniel Nolan
    Product Manager
    Redgate Software
Sign In or Register to comment.