# strange issue when using variable in shell module

**URL:** <https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996>\
**Category:** Ansible Project\
**Created:** [March 28, 2016, 1:00pm UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996 "2016-03-28T13:00:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cai\_Elvis](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Cai\_Elvis](https://forum.ansible.com/u/Cai_Elvis)\
**Post date:** [March 28, 2016, 1:00pm UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996/1 "2016-03-28T13:00:45Z")

</div>

Hi guys

i met a wield issue in ansible when using variable including ‘@’ sign, if my variable including @, it will turn to empty totally and the debug infomation is hello world, when i remove @ sign, the result is normal, is there anyone could help? thanks in advance! :-）

TASK: [vas | debug username] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [cnshget04.xxx] =\> {  
“msg”: “Hello world!”

TASK: [vas | vas installing…] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [cnshget04.xxx] =\> {“cmd”: "/opt/quest/bin/vastool -u ‘’

task file:

- name: vas installing…  
shell: \>  
“{{vastool\_binary}}” -u “{{username}}”

default file:

-sh-4.1$ cat defaults/main.yml | grep username  
username: ‘username’

my playbook:

- role: vas  
username: abc@eapac.abc.se

my ansible version is 1.9.4

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 28, 2016, 3:09pm UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996/2 "2016-03-28T15:09:32Z")

</div>

@ is special in bash, use single quotes to avoid interpolation `-u '{{username}}'`

---

<div class="post-metadata">

**Author:** ![Cai\_Elvis](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Cai\_Elvis](https://forum.ansible.com/u/Cai_Elvis)\
**Post date:** [March 29, 2016, 1:56am UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996/3 "2016-03-29T01:56:43Z")

</div>

thanks for your quick replay, unfortunately, it works the same like before.

TASK: [vas | vas installing…] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [cnshget04.xxx] =\> {“cmd”: "/opt/quest/bin/vastool -u ‘’

task file:

shell: \>  
“{{vastool\_binary}}” -u ‘{{username}}’

在 2016年3月28日星期一 UTC+8下午11:09:38，Brian Coca写道：

---

<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:** [March 29, 2016, 8:02am UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996/4 "2016-03-29T08:02:44Z")

</div>

Shouldn't this be like this:

- role: vas  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;- username: foobar

Johannes

---

<div class="post-metadata">

**Author:** ![Cai\_Elvis](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Cai\_Elvis](https://forum.ansible.com/u/Cai_Elvis)\
**Post date:** [March 30, 2016, 10:20am UTC](https://forum.ansible.com/t/strange-issue-when-using-variable-in-shell-module/20996/5 "2016-03-30T10:20:01Z")

</div>

I think it works, please see my whole yml file.
