Ad-hoc commands

We can check the hostname of IP addresses available in the hosts file:

$ ansible all -a "hostname"
192.168.1.160 | SUCCESS | rc=0 >>
node-ansible1
192.168.1.161 | SUCCESS | rc=0 >>
node-ansible2

The preceding command is equivalent to the following:

$ ansible 192.168.1.160,192.168.1.161 -a "hostname"

By default, Ansible executes the commands in parallel so that they end sooner. If we have two servers, we are practically not going to notice the difference, but as soon as we add several servers, we can verify that it goes faster if we parallelize the execution of commands.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset