In this section you will be creating the Terraform configuration for the Fabric Switches
modules/fabric/inventory.tf
file
touch ~/workspace/ndfclab/terraform/modules/fabric/inventory.tf
code-server -r ~/workspace/ndfclab/terraform/modules/fabric/inventory.tf
To define the fabric switches for our lab, we will be using the ndfc_inventory_devices
resource. This resource allows us to specify the devices that will be part of the fabric, including their roles and configurations.
Notice that we are again leveraging several variables that have been defined in your variables.tf
file.
The depends_on argument is used to ensure that the fabric is created before the inventory devices are processed. This is important because the inventory devices depend on the fabric being in place before they can be added.
resource "ndfc_inventory_devices" "nac_inventory_devices_1" {
fabric_name = var.fabric_name
auth_protocol = "md5"
username = "admin"
password = "cisco.123"
max_hops = 0
set_as_individual_device_write_credential = false
preserve_config = false
save = true
deploy = false
retries = 350
retry_wait_timeout = 20
devices = {
(var.staging-spine1) = {
role = "spine"
discovery_type = "discover"
discovery_auth_protocol = "md5"
}
(var.staging-leaf1) = {
role = "leaf"
discovery_type = "discover"
discovery_auth_protocol = "md5"
}
(var.staging-leaf2) = {
role = "leaf"
discovery_type = "discover"
discovery_auth_protocol = "md5"
}
}
depends_on = [
ndfc_fabric_vxlan_evpn.nac_fabric1,
]
}
In your VSCode application; on the keyword press Ctrl + K + W
. This should close all open tabs to clear your workspace.