Thursday, February 9, 2023

Create NSX-T segments using the terraform


Export the template from GitHub  https://github.com/vmware/terraform-provider-nsxt and modify the template as mentioned below.


“`variables.tf“` file mention the manager IP, user name, password

# NSX Manager
variable "nsx_manager" {
  default = "IP here"
}


# Username & Password for NSX-T Manager
variable "username" {
  default = "user name here"
}

variable "password" {
    default = "password here"
}

 

This is the “`main.tf“` file:

# Prerequisites: 
# 1. Add NSX-T License

# Data Sources we need for reference later
data "nsxt_policy_transport_zone" "overlay_tz" {
    display_name = "Overlay-TZ"
}

data "nsxt_policy_transport_zone" "vlan_tz" {
    display_name = "VLAN-TZ"
}

# NSX-T Manager Credentials
provider "nsxt" {
    host                     = var.nsx_manager
    username                 = var.username
    password                 = var.password
    allow_unverified_ssl     = true
    max_retries              = 10
    retry_min_delay          = 500
    retry_max_delay          = 5000
    retry_on_status_codes    = [429]
}


# Create NSX-T VLAN Segments
resource "nsxt_policy_vlan_segment" "vlan100" {
    display_name = "VLAN100"
    description = "VLAN Segment created by Terraform"
    transport_zone_path = data.nsxt_policy_transport_zone.vlan_tz.path
    vlan_ids = ["11"]
}



No comments:

Post a Comment

ESXI-check multiple ports using one command

  [root@ESXI:~] nc -w 1 -z IP 80-902 Connection to IP 80 port [tcp/http] succeeded! Connection to IP 88 port [tcp/kerberos] succeeded! Conne...