Created Freitag 31 Januar 2020
Default
Location (default): /etc/ansible/hosts
The inventory (Ini format or expandable with inventory plugins like YAML) holds the managed hosts. One can group those hosts. The ansible commands or playbook chooses the hosts to act on with a pattern from the inventory.
E.g.
$ ansible -m <module> [-a <optional module argument>] <host/host group pattern>
Uses the defalut inventory (no option -i) with the function module <module> for <host/host group pattern>.
Custom
Can be defined with the option -i as file or as quoted comma/-separated list on the command line.
File
E.g.
$ ansible -i ~/hosts-m <module> [-a <optional module argument>] <host/host group pattern>
Uses the hosts in the file ~/hosts.
Command line list
E.g.
$ ansible -i "localhost,<PC name>,"-m <module> [-a <optional module argument>] <host/host group pattern>
Uses the hosts listed on the command line in list "localhost,<PC name>,".