Ansible Modules

Modules are the executable plugins that get the real job done. Usually modules can take "key=value" arguments and run in customized way depending up on the arguments themselves. A module can be invoked commandline or can be included in an Ansible playbook. We will discuss playbooks in a minute but for now, let us see the modules in action.

$ ansible -i inventory all -m ping

Above example will use the ping module to ping all the hosts defined in the inventory. There are several modules available in ansible. Let us try another one.

$ ansible -i inventory webservers -m command -a "ls"

In Above example, we used command module to fire ls command on the webservers group. We are now ready for remote execution. Adhoc tasks like restarting web servers or clearing out tmp files can be done easily using command module.