# Ansible - Register variable in not defined

**URL:** <https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954>\
**Category:** Ansible Project\
**Created:** [March 22, 2019, 3:06pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954 "2019-03-22T15:06:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![olyx11](https://avatars.discourse-cdn.com/v4/letter/o/3e96dc/32.png) [@olyx11](https://forum.ansible.com/u/olyx11)\
**Post date:** [March 22, 2019, 3:06pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/1 "2019-03-22T15:06:31Z")

</div>

I am trying to figure out why my variable is not defined and have not been able to find any solutions online.  
Can anyone help?

test.yml

---

<div class="post-metadata">

**Author:** ![syed.qasim.sarfraz](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@syed.qasim.sarfraz](https://forum.ansible.com/u/syed.qasim.sarfraz)\
**Post date:** [March 22, 2019, 3:17pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/2 "2019-03-22T15:17:39Z")

</div>

Try this it worked for me, A play takes a list of tasks so each tasks should start with dash `-`:

---

<div class="post-metadata">

**Author:** ![olyx11](https://avatars.discourse-cdn.com/v4/letter/o/3e96dc/32.png) [@olyx11](https://forum.ansible.com/u/olyx11)\
**Post date:** [March 22, 2019, 3:57pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/3 "2019-03-22T15:57:09Z")

</div>

Thanks Syed. I added a validation step and that is failing.

Updated playbook

---

<div class="post-metadata">

**Author:** ![syed.qasim.sarfraz](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@syed.qasim.sarfraz](https://forum.ansible.com/u/syed.qasim.sarfraz)\
**Post date:** [March 22, 2019, 4:02pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/4 "2019-03-22T16:02:02Z")

</div>

“test\_out”: {  
“changed”: false,  
“failed”: false,  
“msg”: “hello”  
}

there is no key named test here. You need to use ‘test\_out.msg’ above.

---

<div class="post-metadata">

**Author:** ![olyx11](https://avatars.discourse-cdn.com/v4/letter/o/3e96dc/32.png) [@olyx11](https://forum.ansible.com/u/olyx11)\
**Post date:** [March 22, 2019, 4:11pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/5 "2019-03-22T16:11:17Z")

</div>

Yes that worked, but for the client I am working with, I am unable to change the validation. How would I define it so that test\_out.test would work?

---

<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:** [March 22, 2019, 5:05pm UTC](https://forum.ansible.com/t/ansible-register-variable-in-not-defined/29954/6 "2019-03-22T17:05:54Z")

</div>

You can't since debug doesn't return test.
