Ansible Inventory Introduction - Ansible Beginner Tutorials

ansible, Ansible Inventory, Ansible Inventory Tutorials, inventory, Ansible Inventory management, Ansible Inventory configuration, ansible inventory examples

This tutorial explains you about the basics of Ansible Inventory, at the end of this tutorial you will be able to understand What is Ansible Inventory, how to change or create a new inventory rather than using the default inventory, how to define the hosts and host groups.

In the previous posts, we have explained the below topics. Refer those links to understand this topic from basics.

1. What is Ansible, How Ansible works, Ansible Introduction, Ansible Basic Tutorials
2. Ansible Inventory Introduction - Ansible Beginner Tutorials
3. Ansible Ad hoc Commands - Ansible Tutorial for Beginners
4. Managing Ansible Configuration Files Explained with Examples
5. Understanding Ansible Playbook - Write your First Playbook
6. Ansible Roles Explained with Examples - Ansible Tutorials
7. How to use Ansible Vault to Protect Ansible Playbooks

Lets get started.

What is Ansible Inventory?

Ansible Inventory Management - Ansible Tutorials for Beginners

Ansible is an automation tool which works for multiple systems in a infrastructure at the same time. So we should have system lists to manage it. we call that as a inventory. Ansible inventory file has the list of all managed host names one line per host. Inventory management is also important factor in Ansible.
Note : You can define your host names in ipaddress or hostname or fqdn.

By default, this ansible host inventory file is located under /etc/ansible/hosts. Hence if you run a Ansible Playbook or Ansible Ad-hoc commands, that will look the hosts groups under the default file. You can specify a different inventory file using the "-i <path>" option on the command line as shown below.
ansible-playbook -i /root/database_servers install.yml
But remember, We must enable password less SSH authentication between ansible master server host and client hosts, else you would get an error as "Failed to connect to the host via ssh: Permission denied". Refer this link to know how to Configure SSH Passwordless Login Authentication


Hosts Groups Declaration
You can declare the different groups in single host inventory file. For example, If you have database and web servers, then we can declare the list of server names under each groups.
Also, you can simplify the decalarion more, if you have similar hostname starts with same characters.
Either in alphabetic format or numeric format.

Note : A host can be in more than one group.

Inventory File Parameters
By default, Ansible works on SSH port number 22. if you have different port to connect the hosts, then define the hosts as below.
You can also define the connection type and also user depend on the target hosts:
[webservers]     ansible_connection=ssh        ansible_user=mjohn     ansible_connection=ssh        ansible_user=peter
As shown above, some of the ansible parameters mentioned below can be used on need and these are commonly used parameters. You can get more parameters from

Host connection:
Connection type to the host. This can be the name of any of ansible’s connection plugins. SSH protocol types are smart, ssh or paramiko. The default is smart.

General for all connections:
The name of the host to connect to, if different from the alias you wish to give to it.

The ssh port number, if not 22

The default ssh user name to use.

Specific to the SSH connection:
The ssh password to use (never store this variable in plain text; always use a vault)

Private key file used by ssh. Useful if using multiple keys and you don’t want to use SSH agent.

This setting is always appended to the default command line for sftp, scp, and ssh. Useful to configure a ProxyCommand for a certain host (or group).

This setting is always appended to the default sftp command line.

This setting is always appended to the default scp command line.

This setting is always appended to the default ssh command line.

Determines whether or not to use SSH pipelining. This can override the pipelining setting in ansible.cfg.

ansible_ssh_executable (added in version 2.2)
This setting overrides the default behavior to use the system ssh. This can override the ssh_executable setting in ansible.cfg.

Privilege escalation
Equivalent to ansible_sudo or ansible_su, allows to force privilege escalation

Allows to set privilege escalation method

Equivalent to ansible_sudo_user or ansible_su_user, allows to set the user you become through privilege escalation

Equivalent to ansible_sudo_pass or ansible_su_pass, allows you to set the privilege escalation password (never store this variable in plain text; always use a vault.)

Equivalent to ansible_sudo_exe or ansible_su_exe, allows you to set the executable for the escalation method selected

Equivalent to ansible_sudo_flags or ansible_su_flags, allows you to set the flags passed to the selected escalation method. This can be also set globally in ansible.cfg in the sudo_flags option
ansible, Ansible Inventory, Ansible Inventory Tutorials, inventory, Ansible Inventory management, Ansible Inventory configuration, ansible inventory examples, ansible tutorial, ansible tutorial for beginners, ansible beginners tutorial, ansible complete tutorial, ansible dynamic inventory, ansible tower inventory, 
Going forward, we will play more with ansible tool with some test cases. ansible tower, ansible beginners, ansible beginner to pro, ansible list hosts, ansible hosts file inventory, ansible free tutorial,  what is ansible,  ansible tools,  ansible openstack, devops, Introduction to ansible,  ansible terminologies,  ansible tutorial for beginners,  How ansible Works,  ansible Tutorials,  tutorials ansible,  ansible training videos,  ansible tutorial videos,  ansible tutorials for beginners,  ansible introduction,  ansible basics videos,  how does ansible work,  ansible tutorial,  ansible training for beginners
More topics will be added soon. stay connected with us on social dashboard sites.

Support Us: Share with your friends and groups. ansible tutorial for beginners linux,  linux ansible tutorials,  ansible tutorial linux,  ansible labs training
Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
ansible training,  best ansible tutorial,  ansible youtube videos,  ansible video tutorial,  ansible video youtube,  ansible video training,  learn ansible,  ansible fundamentals,  ansible basics,  learn ansible online free,  ansible training course,  learning ansible training videos,  ansible,  ansible for beginners,  ansible explained in detail,  beginners ansible tutorials,  learning ansible,  ansible online training,  why we need ansible,  ansible basics online tutorial,  ansible beginners tutorial,  ansible detailed explanation,  ansible videos download,  ansible training videos on youtube,  ansible training tutorial,  ansible training tutorial for beginners,  ansible learn online,  ansible learning,  learn ansible from scratch,  learn ansible step by step,  ansible basics for beginners,  ansible basics tutorial,  ansible basics video tutorial,  Beginners ansible Tutorial,  Learning ansible with Examples,  ansible tutorial for beginners india,  ansible tutorial for beginners pdf,  ansible tutorial for beginners ppt,  ansible skills,  required skill ansible,  ansible videos, 
October 24, 2017

Post a Comment


Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget