Last updated on: 2023-10-18 04:01:19.

F5OS Terraform Quick Start Guide

In this F5OS Terraform Provider Quick Start Guide, you will deploy a BIG-IP on VELOS hardware using Terraform F5OS resources (see Installing Terraform for detailed steps).

Prerequisites

You require the following five files:

  • Main.tf - Contains resource definitions. Use the Single Responsibility principle to minimize the file size.
  • Variables.tf - Stores all input variables, including all applicable default values.
  • Inputs.auto.tfvars - Defines and manages variables values.
  • Providers.tf - Declares which providers and version to use in the project. Use only on the top-level directory.
  • Outputs.tf- Stores exported data items.

Example files

Use the following file examples to help you automate configurations and interactions for various services provided by F5 VELOS platform and F5 rSeries appliances.

Example variables file

variable "tenant_name" {
  description = "the name of the tenant"
}

variable "tenant_image_name" {
  description = "the name of the image that is to be used for the tenant"
}

variable "tenant_type" {
  description = "type of the tenant"
  default     = "BIG-IP-Next"
}

variable "cpu_cores" {
  description = "the number of vCPUs to be added to the tenant"
  default     = 8
}

variable "running_state" {
  description = "the desired state for the tenant, should be either 'configured' or 'deployed'"
  default     = "deployed"
}

variable "mgmt_ip" {
  description = "ip address of the tenant"
}

variable "mgmt_gateway" {
  description = "management gateway for the tenant"
}

variable "mgmt_prefix" {
  description = "tenant management CIDR prefix"
}

variable "timeout" {
  description = "the number of seconds to wait for the tenant to have the desired running state"
  default     = 360
}

variable "disk_size" {
  description = "minimum virtual disk size required for tenant deployment"
  default     = 15
}

variable "vlans" {
  description = "list of vlans"
  default     = []
}

variable "new_passwd" {
  description = "new password for the bigip next tenant"
  default     = ""
}

Example inputs file

cpu_cores            = 8
cryptos              = "disabled"
tenant_image_name    = "BIGIP-17.1.0-0.0.16.ALL-F5OS.qcow2.zip.bundle"
mgmt_gateway         = "10.1.10.253"
mgmt_ip              = "10.1.10.1"
mgmt_prefix          = 24
tenant_name          = "mybigip"
running_state        = "deployed"
timeout              = 360
tenant_type          = "BIG-IP"
disk_size            = 82
vlans                = [3]

Example outputs file

output "tenant_status" {
  value        = tenant_status
}

Example providers file

terraform {
  required_providers {
    f5os = {
      source  = "F5Networks/f5os"
      version = "1.0.0"
    }
  }
}

provider "f5os" {
  host        = "10.10.100.100"
  username    = "username"
  password    = "passwd"

}

Example main file

resource "random_string" "dynamic_password" {
  length       = 16
  min_upper    = 1
  min_lower    = 1
  min_numeric  = 1
  special      = false
}

resource "f5os_tenant" "bigip_next_tenant" {
  name                = var.tenant_name
  image_name          = var.tenant_image_name
  deployment_file     = var.tenant_deployment_file
  mgmt_ip             = var.mgmt_ip
  mgmt_prefix         = var.mgmt_prefix
  mgmt_gateway        = var.mgmt_gateway
  cpu_cores           = var.cpu_cores
  running_state       = var.running_state
  type                = var.tenant_type
  virtual_disk_size   = var.disk_size
  vlans               = var.vlans
}



Deploy BIG-IP on VELOS

  1. Use Terraform Initialize to prepare the working directory so Terraform can run the configuration.

    $ terraform init
    Initializing the backend...
    
    Initializing provider plugins...
    - Finding f5networks/f5os versions matching "1.0.0"...
    
    Terraform has been successfully initialized!
    
  2. Use Terraform Plan to preview any changes that are required for your infrastructure before applying.

    $ terraform plan -out bigip-velos
    

    Tip

    If you change modules or change backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect, and then prompt you to rerun plan (if necessary).

    Terraform uses the selected providers to generate the following example execution plan. Resource actions are indicated with the + create symbols.

    # module.next_on_velos.f5os_tenant.bigip_next_tenant will be created
    + resource "f5os_tenant" "bigip_next_tenant" {
            + cpu_cores           = 8
            + cryptos             = "disabled"
            + id                  = (known after apply)
            + image_name          = "BIGIP-17.1.0-0.0.16.ALL-F5OS.qcow2.zip.bundle"
            + mgmt_gateway        = "10.1.10.253"
            + mgmt_ip             = "10.1.10.1"
            + mgmt_prefix         = 24
            + name                = "mybigip"
            + running_state       = "deployed"
            + status              = (known after apply)
            + timeout             = 360
            + type                = "BIG-IP"
            + virtual_disk_size   = 82
            + vlans               = [
                + 3,
              ]
      }
    
    # module.next_on_velos.random_string.dynamic_password will be created
    + resource "random_string" "dynamic_password" {
            + id           = (known after apply)
            + length       = 16
            + lower        = true
            + min_lower    = 1
            + min_numeric  = 1
            + min_special  = 0
            + min_upper    = 1
            + number       = true
            + numeric      = true
            + result       = (known after apply)
            + special      = false
            + upper        = true
           }
    
    Plan: 2 to add, 0 to change, 0 to destroy.
    Changes to Outputs: ``+ tenant_status = (known after apply)``
    
    1. Use bigip-velos to save your plan.
  3. Use Terraform Apply to execute the changes defined by your Terraform configuration and create, update, or destroy resources. To perform the previous example actions, run the following apply command and apply the plan:

    terraform apply "bigip-velos"

    For example:

    $ terraform apply "bigip-velos"
    module.next_on_velos.random_string.dynamic_password: Creating...
    module.next_on_velos.random_string.dynamic_password: Creation complete after 0s [id=3XnnlQdoILSgi3Ik]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Creating...
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [10s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [20s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [30s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [40s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [50s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m0s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m10s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m20s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m30s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m40s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [1m50s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Still creating... [2m0s elapsed]
    module.next_on_velos.f5os_tenant.bigip_next_tenant: Creation complete after 2m10s [id=testcbip]
    
    Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
    
    Outputs:
    
    tenant_status = "Running"
    


What’s Next?