LOGBOOK

HELP

Quiz Entry - updated: 2026.11.05

The file /etc/ansible/facts.d/custom.fact has the section [users] with user1 = joe. How do you reference that value in a playbook?

ansible_facts['ansible_local']['custom']['users']['user1'], which returns joe. Custom facts land under ansible_local, then the file name without .fact, then the INI section, then the key.

The fact file in INI:

[packages]
web_package = httpd
db_package = mariadb-server

[users]
user1 = joe
user2 = jane

The same facts in JSON (equivalent, could also be printed by a script):

{
  "packages": { "web_package": "httpd", "db_package": "mariadb-server" },
  "users": { "user1": "joe", "user2": "jane" }
}

Reading the path one level at a time:

Level Comes from
ansible_local all custom facts sit under this key
custom the file name custom.fact without the extension
users the INI section, or the top-level JSON key
user1 the key inside it

To check the structure, print it after facts are gathered: debug: var: ansible_local. Custom facts are then used exactly like built-in ones, for example name: "{{ ansible_facts['ansible_local']['custom']['packages']['web_package'] }}" in a package task.

Go deeper:

From Quiz: ITIA / Ansible Variables, Secrets and Facts | Updated: Nov 05, 2026