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 tasks: - name: Hello shell: "echo hello" tags: - hello - name: Bye shell: "echo bye" tags: - bye
After updating gather_facts: False in playbook if we execute, it will skip collecting facts and directly execute tasks listed.
Good information!
needed a quick explanation, on why not use gather_facts. Thanks.
If you want use gather_factas data you can enable it. If you are sure of the destination evironment it may not required. Basically gather_facts will take some time to get data and this will slowdown your playbook execution.