A simple AnsibleĀ inventory file is a txt file that has a list of managed hosts and groups.
A simple Inventory can be as follows:
- [root@centos9vm ~]# cat inventory
== =====
192.168.132.129
servera.example.com
[webservers]
servera.example.com
serverb.example.com
[dbservers]
serverc.example.com
serverb.example.com
servera.example.com
[myGroups:children]
webservers
dbservers
==== ====
- [root@centos9vm ~]# ansible-navigator inventory -i inventory -m stdout –list
===== ===
{
“_meta”: {
“hostvars”: {}
},
“all”: {
“children”: [
“ungrouped”,
“myGroups”
]
},
“dbservers”: {
“hosts”: [
“serverc.example.com”,
“serverb.example.com”,
“servera.example.com”
]
},
“myGroups”: {
“children”: [
“webservers”,
“dbservers”
]
},
“ungrouped”: {
“hosts”: [
“192.168.132.129”
]
},
“webservers”: {
“hosts”: [
“servera.example.com”,
“serverb.example.com”
]
}
}
=== ====
- [root@centos9vm ~]# ansible-navigator inventory -i inventory -m stdout –graph
==== ===
@all:
|–@ungrouped:
| |–192.168.132.129
|–@myGroups:
| |–@webservers:
| | |–servera.example.com
| | |–serverb.example.com
| |–@dbservers:
| | |–serverc.example.com
| | |–serverb.example.com
| | |–servera.example.com
=======