# "yes" as string (not boolean)

**URL:** <https://forum.ansible.com/t/yes-as-string-not-boolean/35242>\
**Category:** Ansible Developer\
**Created:** [May 27, 2021, 6:44pm UTC](https://forum.ansible.com/t/yes-as-string-not-boolean/35242 "2021-05-27T18:44:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilber\_H](https://avatars.discourse-cdn.com/v4/letter/w/df788c/32.png) [@Wilber\_H](https://forum.ansible.com/u/Wilber_H)\
**Post date:** [May 27, 2021, 6:44pm UTC](https://forum.ansible.com/t/yes-as-string-not-boolean/35242/1 "2021-05-27T18:44:18Z")

</div>

Hi,

Ansible keeps casting my “yes” string variable into a boolean.  
How do I prevent it from doing that?

Regards,  
Wilber H

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 27, 2021, 8:49pm UTC](https://forum.ansible.com/t/yes-as-string-not-boolean/35242/2 "2021-05-27T20:49:00Z")

</div>

Depends, this can happen at many points and for diff reasons, in  
general `|string` filter when you consume it ensures it is a string,  
if it is happening at YAML boundry quote it or use !!str

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 27, 2021, 8:49pm UTC](https://forum.ansible.com/t/yes-as-string-not-boolean/35242/3 "2021-05-27T20:49:49Z")

</div>

[https://hitchdev.com/strictyaml/why/implicit-typing-removed/](https://hitchdev.com/strictyaml/why/implicit-typing-removed/) \<= its  
the opposite of yours, but same issue

---

<div class="post-metadata">

**Author:** ![Wilber\_H](https://avatars.discourse-cdn.com/v4/letter/w/df788c/32.png) [@Wilber\_H](https://forum.ansible.com/u/Wilber_H)\
**Post date:** [June 1, 2021, 1:40am UTC](https://forum.ansible.com/t/yes-as-string-not-boolean/35242/4 "2021-06-01T01:40:43Z")

</div>

Thanks Brian; good info.  
I ended using IFELSE conditions.
