Book Image

Mastering Ansible

Book Image

Mastering Ansible

Overview of this book

Table of Contents (16 chapters)

Developing modules


Modules are the workhorses of Ansible. They provide just enough abstraction to enable playbooks to be stated simply and clearly. There are nearly 150 core modules maintained by the core Ansible development team covering clouds, commands, databases, files, network, packaging, source control, system, utilities, web infrastructure and more. In addition, there are more than 100 other extra modules, largely maintained by community contributors, that expand functionality in many of these categories. The real magic happens inside the module code, which takes in the arguments passed to it and works to establish the desired outcome.

Modules in Ansible are the bits of code that get transported to the remote host to be executed. They can be written in any language that the remote host can execute; however, Ansible provides some very useful shortcuts if writing the module in Python.

The basic module construct

A module exists to satisfy a need—the need to do some piece of work on a host...