What is the difference between `ansible_facts['x']` and the older `ansible_x` variables?
IntermediateConceptVariables, Facts and Precedence
Answer
Facts are available in two forms. ansible_facts['distribution'] is the namespaced form and is always present. The injected form ansible_distribution was created for backwards compatibility and is controlled by inject_facts_as_vars (default true, planned to change to false in a future release).
Use ansible_facts[...] in new code. The injected variables also have a higher precedence than inventory vars, which can cause confusing collisions.
More on Variables, Facts and Precedence
Where can you define variables in Ansible?BeginnerHow do you reference a variable, and when must you quote it?BeginnerGive a summary of variable precedence.IntermediateWhat are the lowest and highest precedence sources, and why does that matter?IntermediateWhat is the difference between a role's `defaults/` and `vars/`?IntermediateWhat are facts and how are they gathered?Beginner