A fact you need is not collected by default, such as a custom application version.
IntermediateScenarioVariables, Facts and Templates
Answer
Situation read → Extend facts.
What I'd do → Drop a script or JSON into /etc/ansible/facts.d/ on the target.
- ansible.builtin.copy:
dest: /etc/ansible/facts.d/app.fact
content: '{"version": "{{ app_version }}"}'
mode: "0644"
- ansible.builtin.setup:
filter: ansible_local
Then use ansible_local.app.version.
Why → Files ending in .fact (JSON, INI or an executable printing JSON) become ansible_local.
Interview tip → Re-run setup after creating the file to refresh within the same play.
More on Variables, Facts and Templates
A variable you set in `group_vars` is being overridden and you do not know where. How do you find the source?IntermediateYou need different values per environment without copying playbooks.BeginnerYou must render an Nginx config with one `server` block per site from a list.IntermediateA template needs the IPs of all hosts in the `db` group, for example for a replication config.IntermediateNothing should be rendered unless a mandatory variable is supplied.BeginnerPer-host values, like `server_id` for MySQL, must be unique and stable.Intermediate