Streamlining BIG-IP Next Deployments: Automate with CI/CD Pipelines Using Terraform Cloud and GitHub
Automation is key to maintaining efficiency and consistency in today's fast-paced IT environment. In this article, I will demonstrate how to automate the deployment of BIG-IP Next configurations using Terraform Cloud and GitHub. By integrating AS3 JSON and Terraform configuration code, you can ensure that any changes made in your GitHub repository automatically trigger Terraform Cloud to deploy the updated configurations to your BIG-IP Next instance via the BIG-IP Next Central Manager.
Key Players:
- BIG-IP Next: Your powerful application delivery controller, offers advanced features for load balancing, security, and more.
- BIG-IP Next Central Manager: The brain of your BIG-IP Next deployment, orchestrating and managing all your BIG-IP instances.
- BIG-IP Next Terraform resources: A powerful interface allowing programmatic control over your BIG-IP configuration, simplifying automation.
- Terraform Cloud: A robust platform for infrastructure-as-code, providing version control, collaboration, and powerful automation tools.
- GitHub: A popular version control system for collaborative software development, where your Terraform configuration files will reside.
- Terraform Agent: A local agent installed on a dedicated VM in your private data center as a bridge between Terraform Cloud and your BIG-IP Next instances.
The Workflow:
- Define your Infrastructure in GitHub: Using the Terraform resources documented at https://clouddocs.f5.com/products/orchestration/terraform/latest/BIG-IP-Next/big-ip-next-index.html#release-notes, you describe your desired BIG-IP Next configuration in code (e.g., creating virtual servers, pools, monitors, and other application services). Store your Terraform code in a GitHub repository.
- Configure Terraform Cloud: Set up a workspace in Terraform Cloud and link it to your GitHub repository. Configure a VCS trigger to automatically initiate a Terraform plan and apply it when changes are made to your code in GitHub.
- Install and Configure Terraform Agent: Set up a VM in your private data center, run Ubuntu, and install the Terraform Agent. Configure the agent to connect to your Terraform Cloud workspace.
- Automatic Configuration: When you push changes to your Terraform code in GitHub, Terraform Cloud detects the update, triggers a Terraform plan, and sends it to the Terraform Agent. The agent then communicates with your BIG-IP Next Central Manager, to implement the necessary changes to your BIG-IP Next instances.
Benefits:
- Simplified Management: No more manual configuration and tedious updates! Terraform Cloud automates deployment, reducing errors and ensuring consistency across your BIG-IP Next environment.
- Increased Efficiency: Spend less time on repetitive tasks and focus on building and deploying applications faster.
- Collaboration and Version Control: Work collaboratively with your team, track changes, and easily revert to previous configurations using GitHub's robust version control capabilities.
- Scalability and Flexibility: Terraform Cloud seamlessly scales to manage large and complex environments, providing flexibility and adaptability for your growing needs.
Getting Started:
- Set up GitHub Repository: Create a repository in GitHub and store your Terraform configuration files there.
You can clone the GitHub repository from https://github.com/f5bdscs/example-AS3.git and begin working on it.
terraform {
required_providers {
bigipnext = {
source = "F5Networks/bigipnext"
version = "1.2.0"
}
}
cloud {
organization = "39nX-example"
workspaces {
name = "39nX-example"
}
}
}
variable "host" {}
variable "username" {}
variable "password" {}
provider "bigipnext" {
username = var.username
password = var.password
host = var.host
}
resource "bigipnext_cm_as3_deploy" "test" {
target_address = "10.1.1.10"
as3_json = file("as3.json")
}
Explanation:
- Terraform Block:
- Defines the required provider bigipnext with source and version.
- Specifies cloud organization and workspace name.
- Variable Declarations:
- host, username, and password are declared as input variables.
- Provider Configuration:
- Uses the input variables for username, password, and host.
- Resource Definition:
- bigipnext_cm_as3_deploy resource with target_address and as3_json file.
Make sure to create and populate the as3.json file with the necessary AS3 declarations. Also, ensure you provide values for host, username, and password when running the Terraform commands.
{
"class": "ADC",
"schemaVersion": "3.45.0",
"id": "example-declaration-01",
"label": "Sample 1",
"remark": "Simple HTTP application with round robin pool",
"next-cm-tenant01": {
"class": "Tenant",
"EXAMPLE_APP": {
"class": "Application",
"template": "http",
"serviceMain": {
"class": "Service_HTTP",
"virtualAddresses": [
"10.1.20.10"
],
"pool": "next-cm-pool01"
},
"next-cm-pool01": {
"class": "Pool",
"monitors": [
"http"
],
"members": [
{
"servicePort": 8080,
"serverAddresses": [
"10.1.20.4"
]
}
]
}
}
}
}
- Configure Terraform Cloud: Create a workspace, link it to your GitHub repository, and set up a VCS trigger to activate plans and apply changes.
Please follow the guide at https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-vcs-change to integrate Terraform Cloud with your GitHub repository.
- Install and Configure Terraform Agent: Set up a VM in your private data center, install the Terraform Agent, and configure it to connect to your Terraform Cloud workspace.
Please follow the guide at https://developer.hashicorp.com/terraform/tutorials/cloud/cloud-agents to install Terraform Cloud agent
- Deploy your configuration: Push your code to GitHub and watch as Terraform Cloud automatically updates your BIG-IP Next instances.
You can watch the Demonstration Video here https://youtu.be/0xEtj-jAepE