Closed dsx1123 closed 3 years ago
Move all the params to blocks, deploy should be at the resource level. deploy logic should only be called when the deploy = true.
@nkatarmal-crest:
Move all the params to blocks
Maybe my ignorance here -- but are you referring to nested config such that each switch is nested under a single resource
block? Would that be something similar to using a for_each
loop in a resource to call multiple devices in a map variable?
I'm experiencing similar behaviours to the above -- (2) spine (4) leaf and attempting to add all to DCNM (with and without parallelism=1
with similar results.
main.tf
resource "dcnm_inventory" "Sandbox_Switches" {
for_each = var.switches
fabric_name = "DevNet_Fabric"
username = "admin"
password = "admin12345"
ip = each.value.ip
role = each.value.role
max_hops = 0
auth_protocol = 0
preserve_config = "false"
deploy = "false"
config_timeout = "10"
}
variable.tf
variable "switches" {
description = "Testbed Sandbox Switches"
type = map
default = {
spine1 = {
ip = "192.168.129.121"
role = "spine"
},
spine2 = {
ip = "192.168.129.122"
role = "spine"
},
leaf1 = {
ip = "192.168.129.123"
role = "leaf"
},
leaf2 = {
ip = "192.168.129.124"
role = "leaf"
},
leaf3 = {
ip = "192.168.129.125"
role = "leaf"
},
leaf4 = {
ip = "192.168.129.126"
role = "leaf"
},
}
}
with my most successful run being:
dcnm-terraform ยป terraform apply -auto-approve -parallelism=1 ~/d/dcnm-terraform
dcnm_inventory.Sandbox_Switches["leaf1"]: Creating...
dcnm_inventory.Sandbox_Switches["leaf1"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["leaf1"]: Still creating... [20s elapsed]
dcnm_inventory.Sandbox_Switches["leaf3"]: Creating...
dcnm_inventory.Sandbox_Switches["leaf3"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["leaf3"]: Still creating... [20s elapsed]
dcnm_inventory.Sandbox_Switches["leaf4"]: Creating...
dcnm_inventory.Sandbox_Switches["leaf4"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["leaf4"]: Still creating... [20s elapsed]
dcnm_inventory.Sandbox_Switches["leaf2"]: Creating...
dcnm_inventory.Sandbox_Switches["leaf2"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["leaf2"]: Still creating... [20s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Creating...
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [20s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [30s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [40s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [50s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [1m0s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [1m10s elapsed]
dcnm_inventory.Sandbox_Switches["spine1"]: Still creating... [1m20s elapsed]
dcnm_inventory.Sandbox_Switches["spine2"]: Creating...
dcnm_inventory.Sandbox_Switches["spine2"]: Still creating... [10s elapsed]
dcnm_inventory.Sandbox_Switches["spine2"]: Still creating... [20s elapsed]
Error: 400 Error : null
Error: 400 Error : null
Error: 400 Error : null
Error: 400 Error : null
Error: 400 Error : null
Error: 400 Error : null
All devices have been added to the inventory -- but roles are not set properly. Links are taking a long time for discovery -- so I don't know if the errors are due to timeouts being hit or if its just cranky due to the amount of work "discovery" entails.
I can't seem to have a full run deploy to completion and have the fabric be discovered as desired.
@qsnyder fix is added in 0.0.3, here is example of plan:
resource "dcnm_inventory" "fabric-demo" {
fabric_name = "fabric-demo"
switch_config {
username = "admin"
password = ""
ip = "172.31.217.122"
preserve_config = "false"
config_timeout = 10
role = "leaf"
}
switch_config {
username = "admin"
password = ""
ip = "172.31.217.123"
preserve_config = "false"
config_timeout = 10
role = "leaf"
}
switch_config {
username = "admin"
password = ""
ip = "172.31.186.154"
preserve_config = "false"
config_timeout = 10
role = "spine"
}
}
@dsx1123 Thanks! I'll take a look next week when back in front of my computer off PTO in my lab. Curiously, was this an API thing -- or something related to the async processing of the inventory? I've noticed the Ansible modules having similar issues.
@qsnyder the process to add a switch on DCNM take several steps, we need to keep monitoring the state of the switch to perform the next step, you can say it is due to the async processing when onboarding the switch. we are looking to improve the performance of the inventory module of ansible also.
btw, feel free to open an issue on ansible collection if you feel like it is not working well.
the issue is fixed on the latest code, will publish to terraform.
Community Note
Terraform Version
DCNM version
Affected Resource(s)
Terraform Configuration Files
Debug Output
output
Panic Output
Expected Behavior
all three switches should be added to fabric
Actual Behavior
only two were added initially, but one of them got deleted, and the plan failed eventually
Steps to Reproduce
terraform apply
Important Factoids
References
0000