Custom conditional statements for networking devices
Although there are no networking-specific Ansible conditionals, conditionals frequently come into play in networking-related Ansible usage.
In networking, it’s common to enable and disable ports. To have data be able to pass through the cable, both ports at the ends of the cable should be enabled, resulting in a connected state (some vendors will use different names for this, but the idea is the same).
Let’s suppose we have two Arista Networks EOS devices, and we issued the ON status on the ports and need to wait for the connection to be up before proceeding.
To wait for the Ethernet4
interface to be enabled, we will need to add the following task to our playbook:
- name: Wait for interface to be enabled arista.eos.eos_command: commands: - show interface Ethernet4 | json wait_for: - "result[0...