# Variable Definition

**URL:** <https://forum.ansible.com/t/variable-definition/25152>\
**Category:** Ansible Project\
**Created:** [August 1, 2017, 3:48pm UTC](https://forum.ansible.com/t/variable-definition/25152 "2017-08-01T15:48:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SARANYA\_devotional\_R](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@SARANYA\_devotional\_R](https://forum.ansible.com/u/SARANYA_devotional_R)\
**Post date:** [August 1, 2017, 3:48pm UTC](https://forum.ansible.com/t/variable-definition/25152/1 "2017-08-01T15:48:51Z")

</div>

Playbook:

vars:  
host: [‘xyz’, ‘gvv’]  
tasks:

- name: check ping  
shell: ping -c 2 {{ host }} \>\> /tmp/test  
with\_items: host

o/p:

failed: [10.100.100.187] (item=host) =\> {“changed”: true, “cmd”: “ping -c 2 [u’xyz’, u’gvv’] \>\> /tmp/test”, “delta”: “0:00:00.010502”, “end”: “2017-08-01 11:44:35.355523”, “failed”: true, “item”: “host”, “rc”: 2, “start”: “2017-08-01 11:44:35.345021”, “stderr”: “ping: unknown host [uxyz,”, “stderr\_lines”: [“ping: unknown host [uxyz,”], “stdout”: “”, “stdout\_lines”: }  
to retry, use: --limit @/home/sara.bckup.priv/ssh.retry

I defined the varaible correctly in vars but when its getting passsed, there is an extra character ‘u’ in the variable. What am I doing wrong here?

---

<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:** [August 1, 2017, 4:02pm UTC](https://forum.ansible.com/t/variable-definition/25152/2 "2017-08-01T16:02:20Z")

</div>

You need to use {{ item }} in the ping command not {{ host }}.
