Ansible – actions BEFORE gathering facts

Gathering facts is equivalent to running the setup module. You can manually gather facts by running it. It’s not documented, but simply add a task like this:

- name: Gathering facts
  setup:

In combination with gather_facts: no on playbook level the facts will only be fetched when above task is executed.

Both in an example playbook:

- hosts: all
  gather_facts: no
  tasks:

    - name: Some task executed before gathering facts
      # whatever task you want to run

    - name: Gathering facts
      setup:

Leave a Comment