I am creating some EC2 instances and later on running a runbook on all of them after terraform finishes.
I need a way to trigger the runbook as soon as Terraform finishes. Cannot really do it via terraform cause it does not have a reasonable sequence in which the instances are created, meaning that i cannot add the dependencies appropriately.
Any help appreciated in order to trigger the runbook as soon as all instances are provisioned and tentacles are registered.
Thanks for reaching out.
Currently, runbooks don’t have deployment target triggers. However, if you don’t need it to be during that same deployment and can be right afterward, a workaround could be you could have a separate project that has a single step, to run a runbook. Then you would create a Deployment Target Trigger that is based on the event group “Machine becomes available for deployment”.
When your EC2 instances have tentacles installed on them, this trigger will automatically run and kick off the runbook.
Would that work for your use case?
Please let me know what you think.
Thank you for your reply.
My question is why should i create a separate project for that? Now for example i have one project with only one runbook within. I don’t have any deployments or releases, I just have this runbook which i publish every time I update the variable set that it uses and run it, in order to execute some actions on the deployed targets.
It is not possible to create a separate process on the deployment section of the same project, that will have the single step to run a runbook, along with the trigger?
Also, please note that on the runbook of the project i am using a variable set which includes variables which are updated right after the tentacle registrations using powershell script and API call, triggered by Terraform. The thing is that each time these variables are changing cause these variables include data such as IPs, hostnames etc. So, it seems that first I have to create a new snapshot of the runbook in order to use the newly updated values in the variable set, and then trigger the runbook. Is there any way to create a snapshot using Powershell?
Thank you again for your reply.
You’re very welcome!
Sorry about the confusion, I incorrectly assumed you had a deployment process already. Yes, you could use that current blank deployment process to be the trigger for the runbook.
As far as creating a new snapshot, we do have an example here that you could test and possibly adapt: OctopusDeploy-Api/REST/PowerShell/Runbooks at master · OctopusDeploy/OctopusDeploy-Api · GitHub
Please let me know if you have any other questions or concerns and please let me know how it goes.
I am testing this process with @1n3l4st1c and we managed to update/publish the runbook with updated variables and all but the deployment process won’t trigger the release with a simple trigger “When Machines found Healthy” … are there any prerequisites before the automatic trigger works? does it have to be a particular release? or do we need to change anything in the lifecycle?
We also tried to wait for all servers before triggering/publishing the runbook but still it does not trigger automatically.
Screenshots for reference.
Thanks in advance!
The only pre-requisite for the trigger is that a successful deployment of the Release needs to occur to the relevant Environment before the Trigger can run. This is because it uses that successful deployment as the template of what to deploy against the new targets.
Also in addition to what Paul said, a better catch all trigger that we suggest to use is “Machine becomes available for deployment”, unless that trigger had something included that you preferred to not happen.
Please let us know how it goes.
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.