Hard-coded NXAPI calls to another switch in multiple modules.

#2 · open · 0 comments

View on GitHub ↗

Mierdin

Currently when a module running on a single switch need info from another switch, I'm hard-coding in a call to that remote switch using statically defined credentials (the IP is pulled via CDP tables, so that's still dynamic). A concrete example is if I know a remote switch via CDP (and as a result it's management address) but I want more, like the HOST ID (show license host-id), I have to connect to that other switch via NX-API, even though my Ansible module is currently running against the local switch. As a result I have to statically define the credentials (or make the assumption that the provided credentials for the local switch will work). Not to mention this places additional work on the module, decreasing performance. This needs to be completely re-designed. Maybe there's an Ansible way to do this better, but I've done it in multiple places now for the sake of getting a working demo together, and it's definitely not ideal. An idea might be to use something else as a unique identifier - something that's available via CDP. This would prevent me from having to reach out to the remote switch at all - I just need to refer to it via this unique key. This assumes that another module has already gone out and pulled some facts about that remote device and mapped them to this key - a great use case for the get_facts module.

Comments