In this post I want to explain you about ansible modules.
Along with the installation of ansible, a large number of modules (module library) are also created. The module library has about 200 modules available.
Module it’s like extension for ansible. A module is usually responsible for its specific and small task.
Modules can be run individually, in ad-hoc commands, or assembled into a specific scenario (play) and then into a playbook.
When calling a module, it needs to pass arguments. Some arguments will control the behavior and parameters of the module, and some will simply pass, for example, the command to be executed.
In this example we are executing a special command using the raw module and passed arguments to it:
$ ansible cisco-routers -i myinventory -m raw -a "Show Clock" -u yourlogin --ask-pass
Running the same task in a playbook would look like this:
- name: run Show Clock
raw: Show Clock
Ansible modules are idempotent. This means that the module can be executed as many times as desired, but the module will only make changes if the system is not in the desired state.
In Ansible, modules are divided into two categories:
core ansible modules are modules that are always installed with Anible. They are maintained by the core Ansible development team.
extra ansible module – these modules are currently installed with Ansible, but there is no guarantee that they will continue to be installed with Ansible. They may need to be installed separately in the future. Most of these modules are supported by the community.