# When is ansible\_mounts defined?

**URL:** <https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679>\
**Category:** Ansible Developer\
**Created:** [August 26, 2021, 12:45pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679 "2021-08-26T12:45:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [August 26, 2021, 12:45pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/1 "2021-08-26T12:45:26Z")

</div>

Hello,

I've been using the ansible\_mounts variable for quite some time, but  
only now I recognise that it is not always defined. Some of my hosts  
just return:

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 26, 2021, 2:08pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/2 "2021-08-26T14:08:58Z")

</div>

short answer: when ansible fact gathering ran and was able to get  
mount information

long answer: basically what the short answer said, but here are some  
reasons Ansible was not able to get the information  
- not running fact gathering  
- fact gathering user not having proper permissions for reading mount info  
- timeout issues when accessing mount information (common with  
shared/network filesystems)  
- the OS is lying to the standard tools used (commonly happens with containers)  
- INJECT\_FACTS\_AS\_VARS is set to false, in which case the info will be  
in ansible\_facts['mounts'] (its always there, inject just adds the  
ansible\_mounts alias)

To find out what exactly is happening i recommend running fact  
gathering directly on the targets that you see are missing  
ansible\_mounts (unless it is the 'inject' issue, which is controller  
configuration).

---

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [August 26, 2021, 2:58pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/3 "2021-08-26T14:58:52Z")

</div>

> - not running fact gathering

It is running. "gather\_facts: yes" is set, I even removed cache files  
to make sure they're re-created.

> - fact gathering user not having proper permissions for reading mount  
> info

User is root, so this should always work.

> - timeout issues when accessing mount information (common with  
> shared/network filesystems)

Well, there are nfs mounts, but they are all accessible. I even checked  
them manually now.

> - the OS is lying to the standard tools used (commonly happens with  
> containers)

The target is a plain FreeBSD installation on metal. No containers, no  
virtualization or such. Other FreeBSD hosts report back fine.

> - INJECT\_FACTS\_AS\_VARS is set to false, in which case the info will be  
> in ansible\_facts['mounts'] (its always there, inject just adds the  
> ansible\_mounts alias)

This isn't set, either.

> To find out what exactly is happening i recommend running fact  
> gathering directly on the targets that you see are missing  
> ansible\_mounts

How would I do that?

To increase the fun: After some back and forth, removing cache files  
and re-trying a few times, now it appears to magically work sometimes  
and sometimes not (especially on one host). This feels like some  
timing-related issue. The machine in question is under some load, so  
getting filesystem information might take some time, indeed, due to  
busy nfs directories.  
How do I find out on which part fact gathering gets actually stuck, and  
how do I increase the timeout value for this?

cu  
&nbsp;&nbsp;Gerrit

---

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [August 26, 2021, 4:14pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/4 "2021-08-26T16:14:20Z")

</div>

Yes, it works when increasing gather\_timeout from 10s to 15s. So there  
is just this global timeout, nothing particular for the mount discovery  
part? Would it be possible to get a warning or an error message when the  
timeout is hit? In this case, the issue was silently ignored (even when  
using -vvv).  
Thank you very much for pointing me into the right direction!

cu  
&nbsp;&nbsp;Gerrit

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 26, 2021, 4:46pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/5 "2021-08-26T16:46:41Z")

</div>

well, 90% of what the timeout does is monitor the mounts (almost  
nothing else has these kind of issues, except networking queries ..  
dns ...)

Recent version of ansible are much more verbose and informative about  
the mounts, so you should get both warnings and the ansbile\_mounts  
var, with the ;mount + error message specific to each mount.

---

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [August 26, 2021, 6:51pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/6 "2021-08-26T18:51:16Z")

</div>

> well, 90% of what the timeout does is monitor the mounts (almost  
> nothing else has these kind of issues, except networking queries ..  
> dns ...)

I see...

> Recent version of ansible are much more verbose and informative about  
> the mounts, so you should get both warnings and the ansbile\_mounts  
> var, with the ;mount + error message specific to each mount.

Using v4.2 here, and no such messages in sight. Which version would I  
have to use to get this feature?

cu  
&nbsp;&nbsp;Gerrit

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 26, 2021, 7:59pm UTC](https://forum.ansible.com/t/when-is-ansible-mounts-defined/35679/7 "2021-08-26T19:59:34Z")

</div>

ansible-core 2.11 and 2.12 have many of the improvements
