If you are not familiar dynamic inventory, check out Ansible - Getting Started with Dynamic Inventory.
This assumes you have the yaml plugin in ansible.cfg enabled, like this.
[inventory] # enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini' enable_plugins = host_list, yaml, ini
This also assumes you have defined your inventory in a yaml file, such as hosts.yml. Let's say hosts.yml contains the following managed hosts (e.g. the target systems).
all: hosts: server1.example.com: server2.example.com: children: linux: hosts: server3.example.com: server4.example.com: windows: hosts: server5.example.com: server6.example.com:
ansible all --list-hosts -vvv
If you get something like this, this suggests you did not define yaml in ansible.cfg properly.
[WARNING]: Unable to parse /etc/ansible/hosts.yml as an inventory source
If the following is returned, the host_list plugin is being used.
Parsed /etc/ansible/hosts.yml inventory source with yaml plugin
Something like this should be returned.
hosts (6): server1.example.com server2.example.com server3.example.com server4.example.com server5.example.com server6.example.com
Or, the ansible-inventory --list command can be used.
Or, the ansible-inventory --graph command can be used.