In a typical DevOps pipeline setup, most commonly we use one or more gates before deploying any changes. After the gates are approved, the deployment can move forward to the environment. If the deployment runs into any issues, the development team needs to quickly find a solution or do a rollback to previously working version. We often need a step after the approvals and before the deployment to run a blueprint of the change that is going to be deployed. This will help the team review and approve or reject the change to go further in the pipeline.
Having such an option in the release orchestration will help the team plan and execute the changes during any major release. In case of any issue they can reject that particular code and avoid any outages in general.
FlexDeploy’s Pre-Deploy workflow and Pre-Deploy step allows you to take a blueprint of a change which can be reviewed before making the change permanently.
In this blog, we will discuss how to configure and use FlexDeploy’s Pre-Deploy feature in a pipeline to review a change before deploying it.
With FlexDeploy, developers have an option to add a Pre-Deploy workflow to their project configuration screen. When a project has a Pre-Deploy workflow selected, FlexDeploy will execute the Pre-Deploy workflow before running any deployment requests. By default, the Pre-Deploy workflow will add two output variables namely FD_REVIEW_REQUIRED and FD_REVIEW_GROUP. These are optional output variables, and developers can decide what values to be set when they design the workflow.
- FD_REVIEW_REQUIRED – Setting true to this boolean variable will indicate that a Review task (Human Task) is created at the end of a successful workflow execution.
- FD_REVIEW_GROUP – Developers can set one ore more comma-separated FlexDeploy groups to assign the Review task. If no group is set, the Review task will be assigned to one of the FD Administrator group. This value is applicable only if FD_REVIEW_REQUIRED is set to true.
Oracle Autonomous Database – Pre-Deploy Terraform Plan
Using the Pre-Deploy workflow and Pre-Deploy step in the pipeline, let’s see how FlexDeploy helps review the Terraform changes before it’s deployed to an environment.
Create a new workflow for executing the terraform script, select the workflow type as Pre-Deploy. (For this blog we are discussing only Pre-Deploy workflow, you will also need to have Build and Deploy workflows.)
In the workflow definition, add the plan operation from the Terraform plugin. Add an assign operation to set the FlexDeploy group. The group used should be active.
The Plan operation in the Terraform plugin supports Pre-Deploy execution to create a review task automatically if there are any changes in the plan. Using the FD_REVIEW_REQUIRED variable as below, the plugin will set the flag at the end of the execution.
In the screen below you can see the output variables. If needed you can set the flag and group to have a default value.
In the project configuration screen, select the Pre-Deploy workflow created in the earlier step.
Pipeline Pre-Deploy Step
Now that the project configuration is done, we need to create a new pipeline with a Pre-Deploy step. In the Pre-Deploy step, select the Terraform project we are going to deploy, and activate the pipeline, and save it.
Create a new release and add the same project configured in the pipeline. Now select the pipeline created above for the release and start the release. When you create a new snapshot, you will see the stage execution for the snapshot running in the Release Dashboard. You can see the Pre-Deploy step to create a new Oracle Autonomous Database is in “Pending Review” status.
Because there are changes, the Pre-Deploy step has created a Review Task. To Review, drill into the step execution to see the execution details. The Workflow Execution screen shows the steps, plan execution, and assignment to a group at the end.
As a Reviewer, select the Reports tab to review the changes. Once reviewed, select the Tasks tab to Approve the Review Task. This will trigger the Deploy step to apply the Terraform changes.
FlexDeploy also shows the Review task in the Human Tasks screen under Tasks -> Human Tasks. The reviewer also gets an email notification with a link to the Review task.
Using the Pre-Deploy execution, we were able to review a Terraform plan and then deploy successfully using FlexDeploy. The Pre-Deploy feature opens up more options to create similar workflows to perform review process before deploying the code. You can use Pre-Deploy for migrating databases, performing scanning for security risks, and more.
FlexDeploy provides you the flexibility to create pipelines that meet your unique needs!