Ansible Inventory and Config Files.
First of all, what is the Ansible inventory?
The inventory is nothing other than either a YAML or INI format config file that
defines the managed nodes that your playbooks will target.
And a playbook, again, we haven't formally gotten there yet,
but that's your main unit of work.
For example,
let's say that you've got a fleet of Windows servers that
all need SQL Server database installed.
You can absolutely define that in your playbook.
And so, inventory is going to have all of your nodes,
DNS names, IP addresses, some combination. And you can do all sorts of
different methods to organize those nodes in your inventory.
And because it's a simple config file, you can have multiple copies and versions.
If an Ansible playbook is ready to run,
the control node will have an order of precedence.
If you have an inventory that's in the playbook folder,
that will be consumed by the playbook automatically. The global
position or the global location for the file is etc/ansible by
default. Normally and by convention, the file is called hosts.
Again, you could have different inventories for different environments.
Maybe you have one inventory for your dev environment,
another for staging, and another for production.
And as you'll see, there's lots of flexibility in how you do these commands.
When we use the ansible playbook CLI command,
we can use the inventory argument to target a custom
inventory file if we have yet a third option.