Skip to content

Use ansible_facts instead of the global 'ansible' namespace for system facts #529

@geerlingguy

Description

@geerlingguy

Right now there are a few instances in the book where I'm using facts like ansible_os_family and ansible_distribution.

Instead, I should start using ansible_facts, like ansible_facts.distribution (or ansible_facts['distribution']), as users could have INJECT_FACTS_AS_VARS set to false, and if so, none of the examples using specific namespaced magic vars will work.

This change was introduced in Ansible 2.5 (I think), therefore it has been present for a few years and will not cause any backwards compatibility issues with any supported Ansible release.

See related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions