This section discusses how to develop, debug, review, and test modules.
Ansible modules are reusable, standalone scripts that can be used by the Ansible API, or by the ansible or ansible-playbook programs. They return information to ansible by printing a JSON string to stdout before exiting. They take arguments in one of several ways which we’ll go into as we work through this tutorial.
See All modules for a list of existing modules.
Before diving into the work of creating a new module, you should think about whether you actually should develop a module. Ask the following questions:
There are a lot of existing modules available, you should check out the list of existing modules at Importing Modules
It’s possible that someone has already started developing a similar PR. There are a few ways to find open module Pull Requests:
If you find an existing PR that looks like it addresses the issue you are trying to solve, please provide feedback on the PR - this will speed up getting the PR merged.
Action plugins get run on the master instead of on the target. For modules like file/copy/template, some of the work needs to be done on the master before the module executes on the target. Action plugins execute first on the master and can then execute the normal module on the target if necessary.
For more information about action plugins, read the action plugins documentation.
Check out the roles documentation.
The following guidelines will help you determine if your module attempts to do too much, and should likely be broken into several smaller modules.
The following topics will discuss how to develop and work with modules: