Ansible Inventory

Inventory is a list of nodes, where #202204272036 run against, managed by #202204272021. Ansible has a default inventory file /etc/ansible/hosts but it could be changed using the option -i. We could create multiple groups that can contain multiple hosts either in domain name or 202206151453# within an inventory.

Note: Although Inventory could be used to store 202205042134#, it is advised to only define them if they are necessary for device connection such as user password and mean of communication.

A typical Inventory is file-based which could be in INI or YAML format. Some are in a service or in git repository. This is shown as follows:

[webservers]  # webservers group
b2bwebprod1 urlpath=https://b2bprod.abc.xyz
b2bwebprod2 ansible_host=10.100.25.3  # set name for IP address 10.100.25.3
b2bwebprod3 ansible_host=10.100.25.4  # set name for IP address 10.100.25.4

[appservers]  # appservers group, contains both IP addresses and domain name
10.25.13.25
10.40.12.44
b2bappprod1
b2bappprod2
b2bappprod3

[frontend:children] # parent group for group webservers and appservers
webservers
appservers
b2bslavedb

[webservers:vars]   # define group variables for webservers group
server_path=/var/www/html

[all:vars]          # define variables for all groups
user_name=ansible
ssh_key=/home/clover/.ssh/ssh.rsa

Note: By default, #202204272021 use Domain Name Server (DNS)# for name lookup. This could be circumvented by using the option ansible_host where custom name is assigned to an IP address.

Note: Using keyword children after the group name impose a hierarchy of groups. Such group can contain both groups and hosts.

Note: Using keyword vars after the group name define group variables which are only able to be used for that group. However, if the name before the keyword is all, the variables could be used by every group or host in the Inventory.

Links to this page
  • Automation Controller

    The basic unit for Automaton Controller is Automation Job. It consists of project (collection of 202204272036# with 202208131616# or within the Automation Controller instance), credential such as CyberArk and Vault and 202204272043# which composed of 202206151453#, username, and access method (202205251209, 202205191908, API). Automation Job could be defined in a Job Template.

  • Ansible Variables

    Variables could be defined in #202204272036 and #202204272043. However, it is recommended to put variables, primarily credentials that are essential for connection such as username and password, into Inventory.

  • Ansible Content Navigator

    We can run inventory command to show the 202204272043# information from all hosts. To list the information from only a specified host or group, pass it in as an argument to the command as in inventory {host/group}. For more verbosity, use the option --list. If verbosity is not desired, use the option --graph instead.

  • Ansible

    Ansible also stores a list of nodes where the playbooks ran against that is managed by itself with 202204272043#.

#git #automation