geerlingguy / geerlingguy/ansible-for-devops

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

Open
#529 0 comments 0 reactions 0 assignees View on GitHub
planned
Dominant language
Python
Stars
9.9k
Forks
3.8k
PR merge metrics
No merged PRs in 30d

Description

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:

- https://github.com/geerlingguy/ansible-role-repo-epel/pull/44
- https://github.com/ansible/ansible/pull/36059

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the book examples for ansible_os_family, ansible_distribution, and other globally injected fact names. Read each matching passage and update the examples to use the corresponding ansible_facts form, then verify that no affected examples still depend on globally injected facts.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible
Domain
devops, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.