This chapter will focus on how to write and test custom modules. We've already discussed how modules work and how to use them within your tasks. To quickly recap, a module in Ansible is a piece of code that is transferred and executed onto your remote host every time you run an Ansible task (it can also run locally if you've used local_action).
From my experience, I've seen custom modules being written whenever a certain functionality needs to be exposed as a first-class task. The same functionality can be achieved without the module, but it will require a series of tasks with existing modules to accomplish the end goal (and sometimes, command and shell modules too). For example, let's say that you want to provision a server through Preboot Execution Environment (PXE). Without a custom module, you would probably use a few shell or command...