Ansible - Inventory File
What is Ansible and Ansible Inventory file?
Table of contents
No headings in the article.
Ansible is a simple open-source IT automation engine that makes configuration management, application deployment, orchestration and provisioning simple, efficient and flexible.
An Ansible inventory file in simple understandable terms is a file that consists of one or more multiple managed nodes/hosts that ansible automation works against.
These are the various ways in which the Ansible inventory file can be specified for the Ansible automation tasks.
1.Using the default Ansible configuration inventory file
The default Ansible configuration inventory file is located under /etc/ansible/hosts on the Ansible control node - a machine that manages the Ansible automation tasks for the various Ansible-managed nodes/hosts/servers specified in the ansible configuration inventory file.
E.g. ansible all -m ping runs the ping module on all the hosts specified in the default ansible configuration file specified in the ansible.cfg file ansible configuration file.
In the screenshot below the hosts file had 1 host's ip specified so the ping command ran for the 1 host defined in the hosts file
2.Using the -i option when running an Ansible commands
E.g. ansible all -m ping -i my_hosts where my_hosts is the custom configuration inventory file in the present working directory that consists of the managed hosts or nodes for which the Ansible automation needs to run.
In the screenshot below the my_hosts file had 1 host's ip specified so the ping command ran for the 1 host defined in the my_hosts file using the -i option
Author : Chandrasekar(Chan) Rajaram
https://www.linkedin.com/in/chan-rajaram-software-engineer/
#devops