Briefly about Inventory Files & Hosts Patterns example
Inventory Files & Hosts Patterns
Ansible’s inventory lists all the platforms you want to automate across. Ansible can at a single instance work on multiple hosts in the
infrastructure.
Setup & Hosts Connection
Follow the below steps to set hosts and then check their connection.
#Set up hosts by editing the hosts' file in the Ansible directory $ sudo nano /etc/ansible/hosts #To check the connection to hosts #First change the directory to /etc/Ansible $ cd /etc/ansible #To check whether Ansible is connecting to hosts, use ping command $ ansible –m ping <hosts> #To check on servers individually $ ansible -m ping server name #To check a particular server group $ ansible -m ping servergroupname
Ansible Hosts Patterns
all – All hosts in the inventory
* – All hosts in the inventory
ungrouped – All hosts in inventory not appearing within a group
10.0.0.* – All hosts with an IP starting 10.0.0.*
webservers – The group webservers
webservers:!moscow – Only hosts in webservers, not also in group Moscow
webservers:&moscow – Only hosts in the group’s webservers and Moscow