How to Migrate Agents from Red Gate Deployment Manager to Octopus Deploy

I can take no credit for the following article. This was written by a Solutions Architect called Chris Gelhaus who works at Alfa Insurance. Chris does not have a blog but he has kindly documented a neat solution to a potentially time consuming task and allowed me to share it on his behalf.

For those that don’t know, a couple of years ago Red Gate released a product called Deployment Manager. It was a release management tool for SQL Server and .NET. One of the things we learned was that there is a very real need for SQL Server release management functionality but that it would be more effective for us to partner with the market leading release management tools and provide a SQL Server plug-in, rather than trying to both create the best release management tool and create the best SQL Server deployment tool at the same time. This new approach allows us to focus on doing an awesome job at the stuff we are really good at without getting bogged down with conflicting objectives.

As a result we decided to retire Deployment Manager and pivot to providing SQL Server plug-ins to other release management tools, starting with Octopus Deploy. This leaves current Deployment Manager customers with the task of switching.

Red Gate and Octopus deploy have worked together to create a slick migration tool for the main component of the product, the ‘server’, but there is still a requirement to swap the ‘agents’ on your target machines to Octopus agents, rather than Deployment Manager agents. In most cases this should be a trivial task but if you have a large number of agents this could be quite time consuming. The solution documented below provides a neat way to automate the process that I believe is worth sharing.

Thank you Chris. If we ever meet face to face I’ll buy you a beer. 🙂

***

This paper describes how to automate Octopus tentacle agent installation and Red Gate agent removal when upgrading from Red Gate Deployment Manager to Octopus Deploy.

Prerequisites

Upgrade to the latest version of Red Gate Deployment Manager.

Install an Octopus Deploy server. You don’t need to have any tentacles deployed.

Download the following components to a work folder on your workstation:

  1. RgPublish.exe command line utility
  2. Nuget.exe command line utility
  3. Octo.exe command line utility (Part of the OctopusTools download)
  4. Latest Octopus.Tentacle agent.
    1. I used Octopus.Tentacle.2.5.9.55-x64.msi
  5. The two PostDeploy.ps1 powershell scripts attached to this document (AY edit: I’ve added them at the bottom of this post)

The process is broken into two parts. Part 1 sets up Red Gate to deploy the Octopus tentacle agent. Part 2 sets up Octopus Deploy to remove the Red Gate agent.

Part 1 – Deploy Octopus Tentacle agent

  1. Create a work folder called InstallOCTDM
    1. Copy Octopus.Tentacle.2.5.9.55-x64.msi  into the folder
    2. Copy OCTDMPostDeploy.ps1 script into the folder and rename it to PostDeploy.ps1
  2. Run RgPublish.exe to build this package. My sample command is below
    1. RgPublish.exe /verbose /source=”.\InstallOCTDM” /version=1.0.1 /packageid=InstallOCTDM /target=feed:http://<RedGateServerName>/nuget/”
    2. You should now have a new package on your Nuget Feed named InstallOCTDM.1.0.1.nupkg
  3. (Optional) Create a new Environment in DM and assign the servers to it you want to install the Octopus Tentacle agent. I created one called DM_Upgrade and placed it at the end of my environment list so it was out of the way
  4. Create a new project inside Red Gate Deployment Manager. I created one called zzDM_Upgrade so it was at the end of my project list and out of the way
  5. Within the project create a new package step and name it “Deploy Agent”
  6. Supply the package feed where the package was published with RgPublish.exe. I used the default Deployment Manager package feed
  7. Supply the package name
  8. Add the target(s) you want to install Octopus tentacle agent on
  9. Add the variable “RedGateNotAWebSite” and give it the value “True”. Assign it to all environments, targets, and steps.
  10. Create a new release using the package built in step 2
  11. Deploy the release to the target server(s)

When the deployment finishes, Octopus Deploy should be installed and a new tentacle should be created, configured and connected to your Octopus Deploy server.

Now you have both the Red Gate and the Octopus agents installed on your target machine. You can deploy through both agents and test to make sure that deployments on the new Octopus agent go as expected.

Part 2 – Red Gate Deployment Manager Agent Removal

Once you’re ready to remove the Red Gate agent, use Octo.exe to build a new nugget package containing the proper PowerShell script.

  1. Create a work folder called UninstallRGDM
    1. Create a placeholder text file so the package has some contect
    2. Copy RGDMPostDeploy.ps1 script into the folder and rename it to PostDeploy.ps1
  2. Run octo.exe to build this package. My sample command is below
    1. Octo.exe pack –id=rgdmUninstall –basePath=.\UninstallRGDM –version=1.0.1
  3. Run Nuget.exe to push the package onto the feed.
    1. NuGet.exe push rgdmUninstall.1.0.1.nupkg -ApiKey <APIKEY> -Source http://<OctopusServerName>/nuget/packages
    2. You should now have a new package on your Nuget Feed named UninstallRGDM.1.0.1.nupkg
  4. Create a project in Octopus and add your server with the Red Gate agent as a target.
  5. Deploy the package to the server. It should run the PowerShell script and remove the Red Gate agent.
  6. Create a project in Octopus and add your server with the Red Gate agent as a target.
  7. Create a new deploy process with a PowerShell step.
  8. Paste the PS script into the script window
  9. Run the process. It should run the PowerShell script and remove the Red Gate agent.

Alternate Uninstall Method (Untested)

  1. Create a project in Octopus and add your server with the Red Gate agent as a target.
  2. Create a new deploy process with a PowerShell step.
  3. Paste the PS script into the script window
  4. Run the process. It should run the PowerShell script and remove the Red Gate agent.

PowerShell Scripts

Script for part 1: Octopus Agent install (OCTDMPostDeploy.ps1)

Start-Process -FilePath "msiexec.exe" -ArgumentList "INSTALLLOCATION=D:\Octopus\Tentacle /i Octopus.Tentacle.2.5.9.555-x64.msi /quiet" -Wait
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe create-instance --instance "Tentacle" --config "D:\Octopus\Tentacle\Tentacle.config" --console
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe new-certificate --instance "Tentacle" --if-blank --console
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe new-squid --instance "Tentacle" --console
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe configure --instance "Tentacle" --reset-trust --console
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe configure --instance "Tentacle" --home "D:\Octopus" --app "D:\Octopus\Applications" --port "10933" --console
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe configure --instance "Tentacle" --trust "YourAgentManagerThumbprintGoesHere" --console
Start-Sleep -Seconds 60
netsh.exe advfirewall firewall add rule "name=Octopus Deploy Tentacle" dir=in action=allow protocol=TCP localport=10933
Start-Sleep -Seconds 60
D:\Octopus\Tentacle\Tentacle.exe service --instance "Tentacle" --install --start --console

Script for part 2: Deployment Manager agent uninstall

$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match "Deployment Agent" }
$app.Uninstall()
Start-Sleep -Seconds 60

Note: These scripts could be improved by adding Octopus variables for customisation.

Leave a Reply

Your email address will not be published.