# Simple assert failure

**URL:** <https://forum.ansible.com/t/simple-assert-failure/31627>\
**Category:** Ansible Project\
**Created:** [November 8, 2019, 9:12pm UTC](https://forum.ansible.com/t/simple-assert-failure/31627 "2019-11-08T21:12:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [November 8, 2019, 9:12pm UTC](https://forum.ansible.com/t/simple-assert-failure/31627/1 "2019-11-08T21:12:54Z")

</div>

Simple, but I can’t figure it out. The following doesn’t appear to be working. Wondering if I have a syntax error?

`

- assert:  
that:
- user is defined  
msg: “Be sure to define the username under defaults/main.yml”

`

Whether it is defined or not in the defaults/main.yml it produces the following:

`

ok: [localhost] =\> {  
“changed”: false,  
“msg”: “All assertions passed”  
}

`

It DOES work if I delete the variable completely instead of just leaving it empty

Thanks in advance

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 8, 2019, 9:17pm UTC](https://forum.ansible.com/t/simple-assert-failure/31627/2 "2019-11-08T21:17:05Z")

</div>

Listing a variable, even as an empty value, still defines it. It can only be undefined, if it hasn’t been listed at all.

You can add a check that is something like the following also:

- user is not none

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [November 8, 2019, 9:38pm UTC](https://forum.ansible.com/t/simple-assert-failure/31627/3 "2019-11-08T21:38:23Z")

</div>

Perfect, thank you
