#
Ansible Modules
This tutorial explains to you how to use modules in Ansible. This tutorial has an example as well.
Ansible modules (also referred to as task plugins or library plugins) are discrete units of code that can be used from the command line or in a playbook task. Ansible executes each module, usually on the remote managed node, and collects return values.
Ansible works by connecting to nodes using ssh and sending small programs called modules to be executed remotely. As you can see, Ansible uses a push architecture, where configuration is pushed from Ansible to servers (targets) without agents, as opposed to the pull model (common in agent-based configuration management systems), where configuration is pulled.
Here you have an Ansible Playbook and the Ansible modules (command, yum, service) are pointed with an arrow:
Ansible modules are grouped on different categories based on their functionality.
So, we can have:
system modules
: user, group, hostname, iptables, lvg, lvol, make, mount, ping, timezone, systemd, servicecommands modules
: command, expect, raw script, shellfiles modules
: archive, copy, file, replace, start, unarchivedatabase modules
: mongodb, mssql, postgresql, mysqlcloud modules
: amazon, azure, docker, google, openstack, atomic, vmwareWindows modules
: win_file, win_copy, win_command, win_regedit, win_service, win_shell
This list of modules is not complete. This is just an example. If you want, you can create your custom modules as well.
Modules can be written in any language capable of returning JSON, although most Ansible modules (except for Windows PowerShell) are written in Python using the Ansible API (this eases the development of new modules).