# Variable is Undefined error

**URL:** <https://forum.ansible.com/t/variable-is-undefined-error/31003>\
**Category:** Ansible Project\
**Created:** [August 9, 2019, 12:49pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003 "2019-08-09T12:49:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nandha\_kumar1](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nandha\_kumar1](https://forum.ansible.com/u/nandha_kumar1)\
**Post date:** [August 9, 2019, 12:49pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/1 "2019-08-09T12:49:13Z")

</div>

Hello Team,

I am trying to use the variable in the following task which i registered in the previous task.  
However, i am getting “variable is undefined error”  
Could you please suggest us,what could be the reason

Thanks,  
Nandhakumar

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 9, 2019, 12:53pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/2 "2019-08-09T12:53:28Z")

</div>

Hi

Could you please tell clearly:

What the relevant tasks/playbooks/code/variables look like

---

<div class="post-metadata">

**Author:** ![nandha\_kumar1](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nandha\_kumar1](https://forum.ansible.com/u/nandha_kumar1)\
**Post date:** [August 9, 2019, 1:14pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/3 "2019-08-09T13:14:59Z")

</div>

Do you want me to post the playbook Dick?

Thanks,  
Nandhakumar

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 1:16pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/4 "2019-08-09T13:16:28Z")

</div>

Hi:

> Hello Team,
> 
> I am trying to use the variable in the following task which i registered in the previous task.  
> However, i am getting “variable is undefined error”  
> Could you please suggest us,what could be the reason

Please share as much details as possible of your code and the way you invoke it from CLI. We cannot guess!

---

<div class="post-metadata">

**Author:** ![nandha\_kumar1](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nandha\_kumar1](https://forum.ansible.com/u/nandha_kumar1)\
**Post date:** [August 9, 2019, 1:23pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/5 "2019-08-09T13:23:33Z")

</div>

Hello Angel,Dick,

Below is my playbook:

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [August 9, 2019, 1:41pm UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/6 "2019-08-09T13:41:21Z")

</div>

As I see, you’re trying to use variables from one host or group of hosts (cmsserver) from another different group (jobserver). Those variables have a name in common but they’re still different; you can’t use reference them as if they were the same.

But I believe this post might help you:

[https://serverfault.com/questions/638507/how-to-access-host-variable-of-a-different-host-with-ansible](https://serverfault.com/questions/638507/how-to-access-host-variable-of-a-different-host-with-ansible)

Hope that helps

---

<div class="post-metadata">

**Author:** ![nandha\_kumar1](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nandha\_kumar1](https://forum.ansible.com/u/nandha_kumar1)\
**Post date:** [August 12, 2019, 7:23am UTC](https://forum.ansible.com/t/variable-is-undefined-error/31003/7 "2019-08-12T07:23:42Z")

</div>

Hello Angel,

i have gone through the document.  
The articles talks about the values which can be gathered os gather\_Facts.  
My case is bit different.Mine is a custom output which i am storing in a different register  
so kindly suggest the way to get a solution for this

Thanks,  
Nandhakumar
