# setting gather\_facts for a role ?

**URL:** <https://forum.ansible.com/t/setting-gather-facts-for-a-role/34270>\
**Category:** Ansible Project\
**Created:** [December 2, 2020, 1:35pm UTC](https://forum.ansible.com/t/setting-gather-facts-for-a-role/34270 "2020-12-02T13:35:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Caillibaud](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@Daniel\_Caillibaud](https://forum.ansible.com/u/Daniel_Caillibaud)\
**Post date:** [December 2, 2020, 1:35pm UTC](https://forum.ansible.com/t/setting-gather-facts-for-a-role/34270/1 "2020-12-02T13:35:01Z")

</div>

Hi,

I saw that I can specify  
&nbsp;&nbsp;gather\_facts: no  
in a playbook or a tasks list, but is it possible to precise it for a role ?

I tried on top of a roles/xxx/tasks.yml (because it's a tasks list) but it  
throw a syntax error while loading yml

Thanks

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 2, 2020, 4:44pm UTC](https://forum.ansible.com/t/setting-gather-facts-for-a-role/34270/2 "2020-12-02T16:44:58Z")

</div>

Gathering facts takes place at the beginning of a play, so why would you want to disable that in a role?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Daniel\_Caillibaud](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@Daniel\_Caillibaud](https://forum.ansible.com/u/Daniel_Caillibaud)\
**Post date:** [December 3, 2020, 7:43am UTC](https://forum.ansible.com/t/setting-gather-facts-for-a-role/34270/3 "2020-12-03T07:43:15Z")

</div>

Because it's the role himself who knows if it needs facts or not (more  
precisely the tasklist of the role should implies gather\_facts or not).

- In a play, I chain roles but I don't know exactly if one role needs fact  
&nbsp;&nbsp;or not

- If I add a --limit to the play run, perhaps that all roles which needs  
&nbsp;&nbsp;facts are skipped (the target isn't in any group needing fact) so  
&nbsp;&nbsp;gather\_facts will be useless in that case.
