# can someone please explain about "undefined" error

**URL:** <https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [January 24, 2020, 2:23am UTC](https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045 "2020-01-24T02:23:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [January 24, 2020, 2:23am UTC](https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045/1 "2020-01-24T02:23:22Z")

</div>

Hello Guys,  
can someone please explain about “undefined” error

Task

- name: reboot if required  
win\_reboot:  
when: update\_count.reboot\_required

TASK [reboot if required] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/windows-playbook/copied.yml:22  
fatal: [[EC2AMAZ-9M186EG.corp.medqia.com](http://EC2AMAZ-9M186EG.corp.medqia.com)]: FAILED! =\> {  
“msg”: “The conditional check ‘update\_count.reboot\_required’ failed. The error was: error while evaluating conditional (update\_count.reboot\_required): ‘update\_count’ is undefined\n\n.\n\nThe offending line appears to be:\n\n tasks:\n - name: reboot if required\n ^ here\n”  
}

Cheers

---

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [January 24, 2020, 1:24pm UTC](https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045/2 "2020-01-24T13:24:43Z")

</div>

At the risk of being rude, I’m not sure what you don’t understand.

You’re querying a hash variable update\_count , and looking for the member named reboot\_required . Where did you define this variable? If you don’t define a variable, then the variable is undefined.

Is there more to this playbook that you didn’t provide?

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [January 24, 2020, 2:07pm UTC](https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045/3 "2020-01-24T14:07:03Z")

</div>

To expand on what Eric said:

Your when: condition refers to a variable called “update\_count”.

At the point where you refer to it, that variable does not exist. I bolded the bits of the error message that really matter:

TASK [reboot if required] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/windows-playbook/copied.yml:22  
**fatal** : [[EC2AMAZ-9M186EG.corp.medqia.com](http://EC2AMAZ-9M186EG.corp.medqia.com)]: FAILED! =\> {  
“msg”: “The conditional check ‘update\_count.reboot\_required’ failed. The error was: error while evaluating conditional (update\_count.reboot\_required): **‘update\_count’ is undefined** \n\n.\n\nThe offending line appears to be:\n\n tasks:\n - name: reboot if required\n ^ here\n”  
}

Common reasons for this error include:- you misspelled it

- you got the CaPiTaLiSaTiOn wrong

- you defined it after first reference

- you defined it for a host other than [EC2AMAZ-9M186EG.corp.medqia.com](http://EC2AMAZ-9M186EG.corp.medqia.com)

- you defined it in a vars file that is not being loaded

- you defined it in a vars file that is not being referenced

- you defined it somewhere where it cannot be referenced

- you rearranged your code and accidentally moved the definition to after the first reference

- update\_count is a field or element of something bigger you forgot to reference first

- you didn’t define it at all

If you’d like more help, post the ENTIRE playbook here (or make it available in e.g. pastebin). Don’t post anything confidential though.

Please post code in a fixed-width font so we can see the indentation.

Regards, K.

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [January 24, 2020, 11:01pm UTC](https://forum.ansible.com/t/can-someone-please-explain-about-undefined-error/32045/4 "2020-01-24T23:01:26Z")

</div>

Got it thanks
