Part 3 – Understanding our First Ansible Command

Technically, we have already run our first ad-hoc command in ansible in our previous post. In this post we will actually understand the command we ran. Since this is the format we in fact use through out our entire Ansible journey, it is good to understand this clearly.

Let’s take a look at the command we ran and output we got. Going by each word below

screenshot-from-2017-03-03-15-34-25

ansible -> keyword to execute ansible commands

all    -> here we can either mention a machine in the inventory against which the modules needs to be executed or just mention all to run against all of them.

screenshot-from-2017-03-03-16-11-17

-i      -> Short for –inventory-file, used to specify the inventory file with managed nodes

-u     -> Short for –user, used to specify the remote user name, the default user is vagrant

-m    -> Short for –module-name, used to specify the module

-k      -> Short for –ask-pass, used to prompt the user for password when executed. Look we actually entered the password.

-v    -> Short for –verbose, used for troubleshooting ssh, use -vvv for detailed information.

The keyword success in the output is self explanatory. “changed” field is the one that needs to be monitored if we actually change anything using our modules. Here we used ping module which basically changes no configuration and hence it is false in our case. pong is the response for ping module – meaning all good.

Hope this was informative. Thanks!

 Part 1 – Introduction to Ansible

Part 2 – Ansible Lab Setup

Part 3 – Understanding our First Ansible Command

Part 4 – More about Inventory File

Part 5 – Ansible Config

Part 6 – Ansible Modules

Part 7 – Ansible Tasks, Plays, PlayBooks

Part 8 – Ansible Play Recap, vars, Notify, Handlers

Part 9 – Ansible Roles

Advertisements

#ad-hoc-command, #ansible-usage