Consuming and Creating Modules

Throughout this book, we have almost constantly referred to and made use of Ansible modules. We have treated these as "black boxes" – that is to say, we have just accepted that they exist and that they will work in a certain documented manner. However, one of the many great things about Ansible is that it is an open source product, and as such, not only can you view and modify its source code, but you can also write your own additions. To date, there are literally thousands of modules available for Ansible, handling everything from simple commands such as copying files and installing packages, through to configuring highly complex and bespoke networking equipment. This large array of modules has grown out of a genuine need to solve problems with Ansible, and the number included with each release of Ansible increases every time.

Sooner or later, you will come across a specific piece of functionality that doesn't exist in any of the current Ansible modules. Of course, you could attempt to fill this gap in functionally, either by writing your own module or by contributing enhancements to one of the existing modules back to the Ansible project for everyone else to benefit from. In this chapter, you will learn the basics of creating your own modules, as well as how to contribute your code back to the upstream Ansible project if you wish.

Specifically, in this chapter, you will cover the following topics:

  • Executing multiple modules using the command line
  • Reviewing the module index
  • Accessing module documentation from the command line
  • Module return values
  • Developing custom modules

Let's get started!

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

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