LOGBOOK

HELP

Quiz Entry - updated: 2026.11.05

What are custom facts, where do they live on a managed host, and how can they be written?

Custom (local) facts are values you define on the managed host itself. setup reads every file or script ending in .fact in /etc/ansible/facts.d/ and adds the result to the host's facts. They can be static INI or JSON files, or executable scripts that print JSON.

Custom facts: a file /etc/ansible/facts.d/custom.fact on the host is read by setup and appears as ansible_facts['ansible_local']['custom'] on the control node

Why put facts on the host at all? Some knowledge belongs to the machine rather than to the inventory: which application release is installed, the host's role in a cluster, a licence key. Stored on the host, the value stays with the machine and any play that targets it can read it, for example to fill a configuration file or decide whether a task should run.

Rules:

  • Location: /etc/ansible/facts.d/ on each managed host (the default).
  • File name: must end in .fact, or it is ignored.
  • Static facts: an INI or JSON file. (YAML is not supported; JSON is the closest format.)
  • Dynamic facts: an executable script that prints JSON to stdout. It must have the execute bit set, otherwise Ansible tries to read it as a static file.

Go deeper:

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