dynamic inventory
An inventory produced at run time by a program or plugin, usually by asking a cloud provider, instead of a file maintained by hand.
In more detail
When machines come and go without anyone editing a file, as with autoscaling, only a source that is consulted on every run stays true. Prefer an inventory plugin to a script. A dynamic group exists only while some host is in it, so a group a play must target should also be declared in a written file.
Related terms
- inventory script — An executable program that prints the inventory as JSON when Ansible runs it with --list, and one host's variables with --host.
- inventory plugin — A plugin that builds inventory from a source such as a cloud account, configured with a small YAML file rather than written as a program.
- static inventory — An inventory written by hand in a file and committed, suitable when the set of machines changes rarely and on purpose.
- autoscaling — A cloud feature that automatically adds servers when demand rises and removes them when it falls.
- keyed group — An inventory plugin setting that creates one group for each distinct value of a host attribute, named from a prefix and the value.
Taught in
- The Static Inventory File — Ansible Configuration Management at Scale
- Dynamic Inventory — Ansible Configuration Management at Scale