# Ansible variable question.

**URL:** <https://forum.ansible.com/t/ansible-variable-question/23560>\
**Category:** Ansible Project\
**Created:** [January 25, 2017, 8:33pm UTC](https://forum.ansible.com/t/ansible-variable-question/23560 "2017-01-25T20:33:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Morgan](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jason\_Morgan](https://forum.ansible.com/u/Jason_Morgan)\
**Post date:** [January 25, 2017, 8:33pm UTC](https://forum.ansible.com/t/ansible-variable-question/23560/1 "2017-01-25T20:33:25Z")

</div>

Hi ,

I have a variable declared as shown below. When the playbook run, the two tasks shown below are skipped. Can someone please clarify the best practice to declare the variable and use as detailed below.

mariadb\_version: 10.1

- name: Start MariaDB 10.0  
service: name=mysql enabled=yes state=started  
when: mariadb\_version == ‘10.0’

- name: Start MariaDB 10.1  
service: name=mariadb enabled=yes state=started  
when: mariadb\_version == ‘10.1’

Thanks

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [January 25, 2017, 8:40pm UTC](https://forum.ansible.com/t/ansible-variable-question/23560/2 "2017-01-25T20:40:13Z")

</div>

Change this:  
mariadb\_version: 10.1

into this:

mariadb\_version: "10.1"

> - name: Start MariaDB 10.0  
> &nbsp;&nbsp;&nbsp;service: name=mysql enabled=yes state=started  
> &nbsp;&nbsp;&nbsp;when: mariadb\_version == '10.0'
> 
> - name: Start MariaDB 10.1  
> &nbsp;&nbsp;&nbsp;service: name=mariadb enabled=yes state=started  
> &nbsp;&nbsp;&nbsp;when: mariadb\_version == '10.1'

Then the second task should work.

Johannes
