# On demand gather\_facts?

**URL:** <https://forum.ansible.com/t/on-demand-gather-facts/12989>\
**Category:** Ansible Project\
**Created:** [June 19, 2013, 7:16pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989 "2013-06-19T19:16:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GW1](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@GW1](https://forum.ansible.com/u/GW1)\
**Post date:** [June 19, 2013, 7:16pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/1 "2013-06-19T19:16:40Z")

</div>

Hi,

I was wondering if there are any plans to add an on demand gather\_facts-like meta task (similar to “- meta: flush\_handlers”)?

Use case:

- during the bootstrapping of a system the play must have “gather\_facts: off” (else: invalid output was: /bin/sh: 1: /usr/bin/python: not found)
- but after python and python-apt or similar minimum has been installed, one could trigger gathering of facts and the rest would work
- now bootstrapping has to be done as a separate play, but it could be part of pre\_tasks

Greetings,  
gw

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 19, 2013, 7:20pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/2 "2013-06-19T19:20:27Z")

</div>

Use setup module in task, it is the one that does it

Brian Coca

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [June 19, 2013, 7:26pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/3 "2013-06-19T19:26:40Z")

</div>

If you use gather\_facts: False in one play, I thought setup would run on a subsequent play where that’s not set false?  
​

---

<div class="post-metadata">

**Author:** ![GW1](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@GW1](https://forum.ansible.com/u/GW1)\
**Post date:** [June 19, 2013, 7:53pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/4 "2013-06-19T19:53:04Z")

</div>

Hi,

I don’t exactly understand what you thought, but it works exactly as Brian said (thanks!).

Inside one play with “gather\_facts: no” this three tasks work as expected:

TASK: [debug msg=“aa {{ansible\_hostname}}”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [xxx.lan] =\> {“msg”: “aa {{ansible\_hostname}}”}  
TASK: [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [xxx.lan]  
TASK: [debug msg=“aa {{ansible\_hostname}}”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [xxx.lan] =\> {“msg”: “aa main”}

Greetings,  
gw

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 19, 2013, 8:31pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/5 "2013-06-19T20:31:54Z")

</div>

@Serge, yes, but you might want it to run for tasks in the first play.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [June 19, 2013, 8:36pm UTC](https://forum.ansible.com/t/on-demand-gather-facts/12989/6 "2013-06-19T20:36:28Z")

</div>

​Then by default they will, in the next separate play, unless you specifiy  
gather\_facts: false​ there.  
If I learnt one thing in ansible, it is to not be afraid to spawn a  
separate play.

But of course, issuing the setup module as a separate task in the first  
play, will also work.

Serge
