# Vars defined within a yml file not changed

**URL:** <https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081>\
**Category:** Ansible Project\
**Created:** [March 22, 2018, 4:12pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081 "2018-03-22T16:12:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmoullia](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cmoullia](https://forum.ansible.com/u/cmoullia)\
**Post date:** [March 22, 2018, 4:12pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081/1 "2018-03-22T16:12:19Z")

</div>

Hi,

This syntax works to override the var “service\_mesh” when we execute this ansible playbook command

“ansible-playbook -i inventory/cloud\_host playbook/post\_installation.yml -e service\_mesh=true”

but the var is not set to true if thethis var is defined within a extra\_vars.yml file and the following command executed

“ansible-playbook -i inventory/cloud\_host playbook/post\_installation.yml -e @extra\_vars.yml”

Snapshot of the extra\_vars.yml file

---

<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, 2018, 4:22pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081/2 "2018-03-22T16:22:28Z")

</div>

service\_mesh=true and service\_mesh: true is not the same.  
The first one is a the string true and the second one is the boolean value true.

So you should always filter the variable thru the bool filter like so

&nbsp;&nbsp;when: service\_mesh | bool == true

Then it will work if service\_mesh is a string or a bool.

---

<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:** [March 22, 2018, 4:30pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081/3 "2018-03-22T16:30:23Z")

</div>

when: service\_mesh | bool

the == is redundant at this point

---

<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, 2018, 4:35pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081/4 "2018-03-22T16:35:14Z")

</div>

I know, but I like reading and using explicit rather than implicit code.

---

<div class="post-metadata">

**Author:** ![cmoullia](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cmoullia](https://forum.ansible.com/u/cmoullia)\
**Post date:** [March 22, 2018, 4:39pm UTC](https://forum.ansible.com/t/vars-defined-within-a-yml-file-not-changed/27081/5 "2018-03-22T16:39:14Z")

</div>

Many thanks for your help. Problem resolved !
