During CfgMgmtCamp & Contributors Summit 2025 in Ghent there was a lot of discussion around set_facts. One of the actions we took was to improve the documentation.
- using variable documentation
- Detail the anti patterns (how not to use set_facts)
- Some real world examples (not made up examples)
- Link back to set_facts & ansible variable precedence page
- Related URL: Controlling how Ansible behaves: precedence rules — Ansible Community Documentation
@felixfontein suggested
maybe we should add an action plugin ‘evaluate’ that evalutes an expression and allows you to register the result and use that, instead of returning
ansible_facts
(likeset_facts
). then you can add an evaluate task, evaluate all expressions there (optionally withrun_once: true
) to get the values evaluated at this point in time, register the result, and then use the result invars:
@Thulium-Drake @kks Thanks for offering to help with this.
Related presentation