# Help with package installation playbook

**URL:** <https://forum.ansible.com/t/help-with-package-installation-playbook/23361>\
**Category:** Ansible Project\
**Created:** [January 3, 2017, 1:24pm UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361 "2017-01-03T13:24:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cosimo\_Streppone](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@Cosimo\_Streppone](https://forum.ansible.com/u/Cosimo_Streppone)\
**Post date:** [January 3, 2017, 1:24pm UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/1 "2017-01-03T13:24:27Z")

</div>

Hi,

have started evaluating ansible playbook functionality to perform  
simple config management tasks.

I have experienced several problems. Tried to get some help on irc,  
and through web searches, but.. well. I'm here 🙂

I'm running the following playbook:

-------8\<-------  
# test.yml

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [January 4, 2017, 4:42am UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/2 "2017-01-04T04:42:47Z")

</div>

Hello Cosimo

Indeed it looks as if facts aren't being gathered, which is kind of  
odd, since it should happen by default. By then each play should  
contain the following at the start.

&nbsp;&nbsp;TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [localhost.localdomain]

Any chance that your ansible.cfg has a non-default value for the  
gathering[1] option? Such as it being set to explicit?

// Andreas

[1]: [https://docs.ansible.com/ansible/intro\_configuration.html#gathering](https://docs.ansible.com/ansible/intro_configuration.html#gathering)

---

<div class="post-metadata">

**Author:** ![Cosimo\_Streppone](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@Cosimo\_Streppone](https://forum.ansible.com/u/Cosimo_Streppone)\
**Post date:** [January 4, 2017, 12:25pm UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/3 "2017-01-04T12:25:43Z")

</div>

> Indeed it looks as if facts aren't being gathered, which is kind of  
> odd, since it should happen by default. By then each play should  
> contain the following at the start.
> 
> &nbsp;&nbsp;TASK [setup]  
> &nbsp;&nbsp;\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> &nbsp;&nbsp;ok: [localhost.localdomain]

I found no indication of this in my run log, so facts gathering was  
not happening.

> Any chance that your ansible.cfg has a non-default value for the  
> gathering[1] option? Such as it being set to explicit?

That's right. I had "gathering=explicit" in my configuration file,  
since I had used ansible only for command execution, and obviously  
gathering facts was wasting lots of time for those kind of tasks.

Thanks, that clears it.

I tried overriding my configuration file from the command line:

&nbsp;&nbsp;ansible-playbook -v -l \<hostname\> -e gather\_facts=true ./playbook.yml

and:

&nbsp;&nbsp;ansible-playbook -v -l \<hostname\> -e gathering=implicit ./playbook.yml

but none worked.  
Changing the playbook file by adding "gather\_facts: true" worked  
instead.  
Not sure if that's an accepted practice. Opinions?

I'm still unsure about this error message when the facts gathering is  
not  
happening:

"Could not detect which package manager to use. Try gathering facts or  
setting the \"use\" option."

what is the "use" option?

Thanks,

---

<div class="post-metadata">

**Author:** ![Andreas\_Olsson](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Andreas\_Olsson](https://forum.ansible.com/u/Andreas_Olsson)\
**Post date:** [January 4, 2017, 6:42pm UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/4 "2017-01-04T18:42:56Z")

</div>

ons 2017-01-04 klockan 13:25 +0100 skrev Cosimo Streppone:

> ...  
> I'm still unsure about this error message when the facts gathering is  
> not happening:
> 
> "Could not detect which package manager to use. Try gathering facts  
> or setting the \"use\" option."
> 
> what is the "use" option?

See [https://docs.ansible.com/ansible/package\_module.html](https://docs.ansible.com/ansible/package_module.html)

&nbsp;&nbsp;- package:  
name: emacs  
use: apt

... which is a bit of a pointless exercise. What might make more sense  
then is something along these lines.

&nbsp;&nbsp;- package:  
name: emacs  
use: "{{ host\_alt\_group\_variable }}"

// Andreas

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 4, 2017, 6:48pm UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/5 "2017-01-04T18:48:50Z")

</div>

gather\_facts and gathering is a directive not a variables, so thats why -e didn't work.  
gather\_facts can only be used in a play.

---

<div class="post-metadata">

**Author:** ![Cosimo\_Streppone](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@Cosimo\_Streppone](https://forum.ansible.com/u/Cosimo_Streppone)\
**Post date:** [January 5, 2017, 10:09am UTC](https://forum.ansible.com/t/help-with-package-installation-playbook/23361/6 "2017-01-05T10:09:46Z")

</div>

Thanks all,
