Ansible tasks and modules
Ansible tasks form the basic building block of running Ansible commands. Ansible tasks are structured in the following format:
$ ansible <options> <inventory>
Ansible modules are reusable code for a particular function, such as running a shell
command or creating and managing users. You can use Ansible modules with Ansible tasks to manage configuration within managed nodes. For example, the following command will run the uname
command on each managed server:
$ ansible -m shell -a "uname" all db | CHANGED | rc=0 >> Linux web | CHANGED | rc=0 >> Linux
So, we get a reply from the db
server and the web
server, each providing a return code, 0
, and an output, Linux
. If you look at the command, you will see that we have provided the following flags:
-m
: The name of the module (shell
module here)-a
: The parameters to the module (uname
in this case)
The command finally ends with where we want to run this...