How can I get a deployment target trigger to wait until machine is fully configured?

how-to
(Bob Walker) #1

It is very common to see users spinning up and down test infrastructure throughout the day. Some users are using VMs, while others are using PaaS services, such as Azure Web Apps. They want to leverage deployment target triggers in Octopus to kick off a deployment as soon as the machine is ready.

When spinning up VMs it is very common to run a bootstrap script to install various software needed (IIS, .NET Core, etc) along with the tentacle. Sometimes the software requires a restart of the VM. But the tentacle needs to be installed and registered along with the installs of IIS, .NET Core and other software.

How can I tell the trigger to wait until after the other software finishes installing and any necessary reboots finish?

(Bob Walker) #2

Deployment target triggers have an event category called Machine deployment-related property modified. We will be leveraging that along with roles to solve this.

Please note: I am doing this through the UI, but you can easily do this through the API using a PowerShell script. See example here.

First, update the trigger to look for that event. Make note of the role the deployment is looking for.

Next, when the machine is first added, the specific role Trident-Web is not included.

In this example, I have two targets in development, d-Trident and d-trident-test. d-trident has the role Trident-Web associated with it.
image

I do a test deployment to the environment and only d-Trident is deployed to.

I then add the new role to d-trident-test.

The trigger sees that change and deploys to that new target.

TL;DR, use project-specific roles and add the target without the project-specific role. Setup the deployment trigger to watch for when roles are added. Once the target is ready, add the role and let the trigger do its work.