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.
oracle-server1.learnitguide.net
oracle-server2.learnitguide.net
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

ALSO WATCH THIS "ANSIBLE INVENTORY MANAGEMENT" TUTORIAL VIDEO FREE ON OUR YOUTUBE CHANNEL

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.
[database-servers]
oracle-a.learnitguide.net
oracle-b.learnitguide.net
oracle-c.learnitguide.net
oracle-d.learnitguide.net
[webservers]
web1.learnitguide.net
web2.learnitguide.net
web3.learnitguide.net
Also, you can simplify the decalarion more, if you have similar hostname starts with same characters.
[database-servers]
oracle-[a-d].learnitguide.net 
[webservers]
web[1-3].learnitguide.net
Either in alphabetic format or numeric format.

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

Inventory File Parameters
[ads-post]
By default, Ansible works on SSH port number 22. if you have different port to connect the hosts, then define the hosts as below.
web1.learnitguide.net:4301
You can also define the connection type and also user depend on the target hosts:
[webservers]
web1.learnitguide.net     ansible_connection=ssh        ansible_user=mjohn
web2.learnitguide.net     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 ansible.org.

Host connection:
ansible_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:
ansible_host
The name of the host to connect to, if different from the alias you wish to give to it.

ansible_port
The ssh port number, if not 22

ansible_user
The default ssh user name to use.

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

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

ansible_ssh_common_args
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).

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

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

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

ansible_ssh_pipelining
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
ansible_become
Equivalent to ansible_sudo or ansible_su, allows to force privilege escalation

ansible_become_method
Allows to set privilege escalation method

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

ansible_become_pass
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.)

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

ansible_become_flags
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

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

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