# CD3 Automation Toolkit Integration with OCI Full Stack DR

Infrastructure as Code (IaC) is essential in the cloud because it automates infrastructure provisioning, ensures consistency, and improves scalability. It helps reduce costs, enhances security, and improves administrator productivity. IaC also integrates well with DevOps practices, enabling agile development and efficient multi-cloud or hybrid cloud management. By treating infrastructure as code, teams can version control, collaborate, and standardise deployments, resulting in faster, more reliable cloud operations.

In Oracle Cloud Infrastructure (OCI), the CD3 Automation Toolkit is available to assist our customers in beginning their IaC journey using Excel templates. CD3 stands for **Cloud Deployment Design Deliverable**. The CD3 Automation Toolkit enables users to efficiently build, export, and manage OCI resources by transforming Excel templates into fully functional Terraform modules in just minutes. The CD3 Toolkit also provides scripts that use OCI SDK modules, available as Python scripts. The CD3 Toolkit ensures seamless resource management through the OCI DevOps GIT service and Jenkins Pipelines.

For more information, please visit [CD3 Documentation](https://oracle-devrel.github.io/cd3-automation-toolkit/latest/cd3-overview/).

### Getting Started with CD3

There are two ways to install and use CD3

1. OCI Resource manager stack
    
2. Manual Container launch
    

Depending on your preference, you can install CD3; in this example, I have used the Manual Container launch approach (Option 2). For more details, refer to [CD3 docs](https://oracle-devrel.github.io/cd3-automation-toolkit/latest/install-cd3)

I have built the current CD3 v2024.4.1 image and started the container cd3-toolkit-1. The below screenshot shows that I could run the <mark>exec</mark> into the running container.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728294619298/4208c3ba-a202-45b1-88f7-759f51b5e5f2.png align="center")

### **Connect the container to OCI Tenancy and use CLI.**

1. After completing the required prerequisites, I have initialised the environment. You must update all the required details in the tenancyconfig.properties file. Please take a look at the [tenancy configuration](https://oracle-devrel.github.io/cd3-automation-toolkit/latest/connect-container-to-oci-tenancy/) for more details.
    

```plaintext
cd /cd3user/oci_tools/cd3_automation_toolkit/user-scripts/
```

```plaintext
python createTenancyConfig.py tenancyconfig.properties
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728298936184/18ca17b1-399e-4a22-af77-6861e7536a67.png align="center")

2. I have used “fsdrdemo” as a prefix, which you can see in the generated folder structure and file names.
    
3. I will use the toolkit with CLI, but integration with Jenkins is also available. To use Jenkins, you must provide the required parameters in the **tenacyconfig.properties** file.
    
4. The next step is to update the **fsdrdemo\_setUpOCI.properties** file and run the [**setUpOCI.py**](http://setUpOCI.py) script. For more details, please refer to the CLI configuration.
    

```plaintext
cd /cd3user/oci_tools/cd3_automation_toolkit/
```

```plaintext
python setUpOCI.py /cd3user/tenancies/fsdrdemo/fsdrdemo_setUpOCI.properties
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728299079964/77e48025-038a-4646-987f-96b06249dec5.png align="center")

You can manage the various supported services for your OCI Infrastructure using the CD3 toolkit.

### Full Stack DR integration with CD3 toolkit

For Full Stack DR integration with the CD3 toolkit, the automation is available as Python scripts that use OCI Full Stack DR SDKs. CD3 enables users to export and update Full Stack DR plans. Different DR plans can be exported into separate Excel tabs. DR plan steps can be updated in Excel and then applied to the Full Stack DR using the toolkit.

**Common Use Cases:**

These scripts will be helpful for the below-mentioned Full Stack DR use cases.

* If an existing DR Protection group member is updated in the Full Stack DR, the DR plan gets deleted. To handle this, export all *User-defined steps* to CD3 Excel and use this data to recreate the new DR plan after updating a member.
    
* Clone the *User-Defined Steps* from one plan to another within the same region or across regions.
    
* Manage the *User-Defined Steps* in DR plans with an Excel spreadsheet.
    

**Features:**

* Easy to manage and update *User-Defined Steps*.
    
* The order of the DR Plan's steps is preserved in the Excel sheet, allowing steps to be created in the same sequence as desired in the console.
    
* A single Excel sheet can manage all DR Switchover and Failover plans.
    

### Update Full Stack DRPG members:

Let’s assume we need to modify the members of the DR protection groups. If you add or modify the members in the DRPG, the existing DR plans will be deleted. Assuming this DR plan has multiple user-defined plan groups/steps, manually creating those steps using the OCI console will be time-consuming. Let’s use the CD3 toolkit FSDR scripts to achieve this task. We are going to perform the following tasks:

1. Export the existing DR plan - Using CD3 scripts
    
2. Modify the members in DRPG - Using OCI Console
    
3. Create the new DR plan - Using OCI Console
    
4. Export the new DR plan - Using CD3 scripts
    
5. Update the new DR plan - Using CD3 scripts
    

**Export the existing DR plan - Using CD3 scripts:**

1. We already have an existing DRPG pair, with a moving instance and volume group added to the Primary DRPG. In addition to the built-in plan groups, I have created and customised the switchover plan with various user-defined plan groups and steps.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728300335153/bde8ca63-fe0b-42bf-b418-ca0071766d88.png align="center")

2. Run the setUpOCI.py script and select the OCI FSDR option
    

```plaintext
python setUpOCI.py /cd3user/tenancies/fsdrdemo/fsdrdemo_setUpOCI.properties
```

**<mark>Enter Other OCI Tools - Option 17</mark>**

**<mark>Enter OCI FSDR - Option 3</mark>**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728300647710/d69f84c3-ca68-482c-9697-647e484f0ae7.png align="center")

3. We have two options ( Export DR plan and Update DR plan); since we are going to take an Export of the current DR plan, select Export DR plan - 1
    
    **<mark>Enter Update DR plan - Option 2</mark>**
    
4. It will prompt you to provide the Excel file name, Excel sheet name and DR plan OCID.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728306460496/8119dcc7-d839-44d9-b8ba-65e03e324311.png align="center")
    
    **Excel File name: fsdrdemo\_oci\_fsdr-plan.xlsx**
    
    **Sheet Name: FSDR-Plan**
    
5. The file will be generated in the “/cd3user/tenancies/fsdrdemo/othertools\_files” folder.
    
    ```plaintext
    [cd3user@f52b32925428 othertools_files]$ pwd
    /cd3user/tenancies/fsdrdemo/othertools_files
    [cd3user@f52b32925428 othertools_files]$ ls -ltr
    total 24
    -rw-r--r-- 1 cd3user cd3user 23235 Oct  7 11:33 fsdrdemo_oci-fsdr-plan.xlsx
    [cd3user@f52b32925428 othertools_files]$
    ```
    
6. Since the excel file is inside the container, you need to copy to the local folder to access the file. This can be done by using the below docker command. Make sure to replace the docker container id and folder structure. In my example. **<mark>f52b32925428</mark>** is my docker container id and **<mark>/Users/surajramesh/cd3/cd3-data </mark>** local folder where i want to copy the file.
    

```plaintext
 docker cp f52b32925428:/cd3user/tenancies/fsdrdemo/othertools_files/fsdrdemo_oci-fsdr-plan.xlsx /Users/surajramesh/cd3/cd3-data
```

7. You can verify the DR plan details from the excel sheet. Refer to the Readme sheet for the instructions of how to use the excel template. FSDR-Plan sheet will have both the built-in and user-defined plan groups/steps with all the attributes.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728301616218/28076e13-183f-4ac5-847a-d7869cbb78f9.png align="center")
    

**Modify the members in DRPG and Create the new DR plan using OCI Console:**

1. Add new compute member in the Standby DRPG.
    
2. Existing DR plan gets deleted.
    
3. Create the new Switchover plan.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728303951754/5fee5aa1-c95b-494b-ba17-fbbc6db5c191.png align="center")
    
4. Gather the OCID of the new DR plan.
    
5. **Follow the same process as mentioned in the above mentioned export DR plan steps, but make sure you provide the new sheet name and the new DR plan OCID which we generated now in the DR plan OCID details and copy the sheet to the local folder.**
    
6. I have provided **FSDR-New-Plan** in the sheet name and new DR plan OCID generated.
    
7. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728303579671/4ee088d1-6881-42b4-bb65-63d0957157a1.png align="center")
    
    Copy the excel sheet to the local folder.
    

```plaintext
 docker cp f52b32925428:/cd3user/tenancies/fsdrdemo/othertools_files/fsdrdemo_oci-fsdr-plan.xlsx /Users/surajramesh/cd3/cd3-data
```

8. Now you will have **FSDR-New-Plan** sheet with the new DR plan details with only built-in plan groups.
    

**Update the new DR plan - Using CD3 scripts**

1. Let’s copy the required User-defind plan groups and steps from the **FSDR-Plan** ( old DR plan) to the **FSDR-New-Plan** (new DR plan) sheet.
    
2. You can refer to the Readme sheet in the generated excel sheet of updated the various required fields during the update DR plan command.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728302795494/58c03e3e-5179-4236-a090-ca165fbb6a3e.png align="center")

3. Copy the required user-defined group and steps from the FSDR-Plan sheet to the FSDR-New-Plan sheet. Make sure you leave the id,steps.id value as empty and follow other instuctions as mentioned in Readme. You can copy and paste in the specific order as per the original DR plan. Don’t modify the built-in plan groups and steps. Make sure the readme file instructions are correctly followed. Once its done, save the file.
    
4. Copy the Update excel file from the local system to the docker container using the below command.
    

```plaintext
 docker cp /Users/surajramesh/cd3/cd3-data/fsdrdemo_oci-fsdr-plan.xlsx f52b32925428:/cd3user/tenancies/fsdrdemo/othertools_files/fsdrdemo_oci-fsdr-plan.xlsx
```

5. Run the setUpOCI.py script and select the OCI FSDR option
    

```plaintext
python setUpOCI.py /cd3user/tenancies/fsdrdemo/fsdrdemo_setUpOCI.properties
```

**<mark>Enter Other OCI Tools - Option 17</mark>**

**<mark>Enter OCI FSDR - Option 3</mark>**

**<mark>Enter Update DR plan - Option 2</mark>**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728305797474/02cd986f-399f-427f-92da-5e93e6bad7c5.png align="center")

6. Verify the updated DR plan in the OCI console. It should have all the required user-defined groups and steps in the required order.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728306631742/850edbee-bc4c-4c18-87fb-c9d969f2f36e.png align="center")
    

### **Standalone FSDR Scripts:**

As mentioned earlier, CD3 toolkit offers broad capabilities of managing OCI Infrastructure using excel based templates. In case if you would like just use the FSDR scripts alone, you can also use as a standalone scripts.

Excel template, export, and update scripts are available [here](https://github.com/oracle-devrel/cd3-automation-toolkit/tree/main/othertools/oci-fsdr). You need to make sure you have installed the required Python packages and have required OCI authentication to use those scripts.

### **Conclusion:**

The CD3 Automation Toolkit offers a powerful and efficient way to manage OCI resources through Infrastructure as Code and scripts. By leveraging Excel templates, users can easily export, update, and manage Full Stack Disaster Recovery plans, ensuring seamless integration and management of user-defined steps. The toolkit's ability to automate and streamline these processes not only saves time but also reduces the risk of errors associated with manual configurations. Additionally, the option to use FSDR scripts as standalone tools provides flexibility for users who wish to focus solely on disaster recovery management. Overall, the CD3 Automation Toolkit enhances the agility and reliability of cloud operations, making it an invaluable resource for organizations utilizing OCI.

### Additional Resources:

* [**OCI Full Stack Disaster Recovery Documentation**](https://docs.oracle.com/en-us/iaas/disaster-recovery/index.html)
    
* [**Full Stack DR run command**](https://docs.oracle.com/en/learn/full-stack-dr-run-command/)
    
* [**Full Stack DR IAM policies**](https://blogs.oracle.com/maa/post/iam-policies-fullstackdr)
    
* [**OCI Full Stack Disaster Recovery - User defined group scripts**](https://github.com/oracle-samples/full-stack-disaster-recovery)
    
* [**Join #full-stack-dr public slack channel**](https://bit.ly/odevrel_slack)
    
* [CD3 Toolkit](https://oracle-devrel.github.io/cd3-automation-toolkit/latest/)
    
* [Join CD3 toolkit slack channel](https://oracle-devrel.github.io/cd3-automation-toolkit/latest/queries/)
