# Random undefined variables (facts) since ansible 2.0 upgrade

**URL:** <https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 3, 2016, 2:56pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440 "2016-02-03T14:56:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 3, 2016, 2:56pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/1 "2016-02-03T14:56:26Z")

</div>

Some ansible playbook runs will work on most hosts, but 1-3 will fail with an undefined variable that is an ansible fact. Run it a second time and it works.  
Example:

fatal: [wdv-sitefinity1]: FAILED! =\> {“failed”: true, “msg”: “ERROR! The conditional check ‘ansible\_os\_family == ‘Windows’’ failed. The error was: ERROR! error while evaluating conditional (ansible\_os\_family == ‘Windows’): ERROR! ‘ansible\_os\_family’ is undefined\n\nThe error appears to have been in ‘/home/icansible/ansible/roles/newrelic/tasks/main.yml’: line 11, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: create temp directory\n ^ here\n”}

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 11, 2016, 12:31am UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/2 "2016-02-11T00:31:59Z")

</div>

This is still occurring during our full site.yml run, but it’s so far impossible to replicate in a small example. It only occurs on our full site.yml run with no limits, any attempt to limit to certain hosts or tags result in no errors.

---

<div class="post-metadata">

**Author:** ![Alex\_Leonhardt](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Alex\_Leonhardt](https://forum.ansible.com/u/Alex_Leonhardt)\
**Post date:** [February 11, 2016, 7:20am UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/3 "2016-02-11T07:20:13Z")

</div>

I had something like it, not on Windows though,at the time the problem was that I set it not to gather\_facts, when I actually tried to use a few facts later on. May not be the same but may be worth checking…

Alex

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 11, 2016, 1:28pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/4 "2016-02-11T13:28:38Z")

</div>

In our case, the facts are being gathered, and used other plays included in site.yml, but later on in a subsequent play the a fact that was defined previously is suddenly undefined, on some random hosts, but not all. It’s happening on windows and linux hosts.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 11, 2016, 4:48pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/5 "2016-02-11T16:48:35Z")

</div>

Do you have fact gathering set to smart in your ansible.cfg?

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 11, 2016, 5:32pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/6 "2016-02-11T17:32:02Z")

</div>

We do, and have been looking at that. The facts for all hosts are getting gathered/refreshed during the first included playbook in site.yml, and the cache is not supposed to be expiring for 3 hours, with our entire run taking less than 2 hours. The cache files are present on disk, etcetera.

We did launch a site.yml run with fact caching commented out of ansible.cfg, waiting to see how that run works.

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 11, 2016, 6:20pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/7 "2016-02-11T18:20:51Z")

</div>

Turning off fact caching completely did not improve the situation.

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [February 12, 2016, 7:59pm UTC](https://forum.ansible.com/t/random-undefined-variables-facts-since-ansible-2-0-upgrade/20440/8 "2016-02-12T19:59:28Z")

</div>

Spoke too soon, turning off fact caching fixed or worked around the problem. Opened a bug report  
[https://github.com/ansible/ansible/issues/14456](https://github.com/ansible/ansible/issues/14456)
