Writing your own custom module
By now, you may get the feeling that network management in Ansible is largely dependent on finding the right module for your task. There is certainly a lot of truth in that logic.
Modules provide a way to abstract the interaction between the managed host and the control machine; they allow us to focus on the logic of our operations. Up to this point, we have seen the major vendors providing a wide range of modules for Cisco, Juniper, and Arista.
Using the Cisco Nexus modules as an example, besides specific tasks such as managing the BGP neighbor (nxos_bgp
) and the aaa server (nxos_aaa_server
), most vendors also provide ways to run arbitrary show (nxos_command
) and configuration commands (nxos_config
). This generally covers most of our use cases.
Starting with Ansible 2.5, there is also the streamline naming and usage of network facts modules.
What if the device you are using does not currently have the module for the task...