What is the `constructed` inventory plugin?

AdvancedConceptInventory
Answer

ansible.builtin.constructed builds extra groups and variables from the hosts discovered by other inventory sources, using Jinja2 conditions and host variables. It is placed in the same inventory directory and runs after the other sources.

# inventory/zz_constructed.yml
plugin: ansible.builtin.constructed
strict: false
groups:
  prod_web: "env == 'prod' and 'web' in role"
keyed_groups:
  - key: ansible_facts.distribution
    prefix: os
compose:
  deploy_dir: "'/opt/' ~ app_name"

It lets one team own the cloud inventory while another layers logical grouping on top, without editing the plugin config.

All Ansible questions Roadmap: Ansible

More on Inventory