Ansible – disable gather facts


When we execute an ansible playbook by default it will gather facts of operating system first and then execute tasks listed in it.

Its always not required to gather facts & if we have too many hosts it will take more time to execute a playbook.

To mitigate this we need to disable gather facts with “gather_facts” attribute in ansible playbook.

By default gather_facts attributes value is True, to disable it we need to set it as False.

gather_facts: False

Here is my play book example with gather_facts: False

- hosts: all
  gather_facts: False
    - name: Hello
      shell: "echo hello"
         - hello

    - name: Bye
      shell: "echo bye"
         - bye

After updating gather_facts: False in playbook if we execute, it will skip collecting facts and directly execute tasks listed.

One comment on “Ansible – disable gather facts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s