Sobes.tech
Junior — Middle

In what situations does Ansible execute facts?

sobes.tech AI

Answer from AI

In Ansible, facts are collected automatically at the beginning of playbook execution on each target host. This occurs before task execution to gather system information — for example, OS version, available resources, network interfaces, etc.

Facts are used for decision-making in the playbook, conditional task execution, and parameter configuration. If fact gathering is explicitly disabled in the playbook (gather_facts: no), they are not collected automatically, but can be obtained manually using the setup module at the needed moment.

Thus, fact collection occurs:

  • By default, at the beginning of the playbook
  • When explicitly invoking the setup module
  • If fact gathering is disabled, it does not happen automatically.
In what situations does Ansible execute facts? — DevOps - sobes.tech