The lookup function
You can use thelookupfunction to populate variables dynamically. Ansible evaluates the value each time it is executed in a task (or template).
The first argument to thelookupfunction is required and specifies the name of the lookup plugin. If the lookup plugin is in a collection, the fully qualified name must be provided, since thecollections keyworddoes not apply to lookup plugins.
Thelookupfunction also accepts an optional boolean keywordwantlist, which defaults toFalse. WhenTrue, the result of the lookup is ensured to be a list.
Refer to the lookup plugin’s documentation to see plugin-specific arguments and keywords.