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.

Use 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_config) 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 that you are looking for? In this section, we will look at several ways that we can remedy this situation by writing our own custom module.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.102.79