# Does user or host of playbook can be set by variable in version 1.4 ?

**URL:** <https://forum.ansible.com/t/does-user-or-host-of-playbook-can-be-set-by-variable-in-version-1-4/14068>\
**Category:** Ansible Project\
**Created:** [December 5, 2013, 5:50am UTC](https://forum.ansible.com/t/does-user-or-host-of-playbook-can-be-set-by-variable-in-version-1-4/14068 "2013-12-05T05:50:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rella.guo](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rella.guo](https://forum.ansible.com/u/rella.guo)\
**Post date:** [December 5, 2013, 5:50am UTC](https://forum.ansible.com/t/does-user-or-host-of-playbook-can-be-set-by-variable-in-version-1-4/14068/1 "2013-12-05T05:50:29Z")

</div>

Hello all,

I am going to update my playbook to upgrade ansible 1.0 to 1.4.  
As we know, ansible 1.4 deprecates “when\_” and ${foo} and $foo.  
In my playbook, user and hosts also use $user and $hosts. In 1.0, it works well. In 1.4, I should change to {{ user }} and {{ hosts }}.  
But I met the error and the error message is:

sudo: yes  
user: {{user}}  
^  
This one looks easy to fix. YAML thought it was looking for the start of a  
hash/dictionary and was confused to see a second “{”. Most likely this was  
meant to be an ansible template evaluation instead, so we have to give the  
parser a small hint that we wanted a string instead. The solution here is to  
just quote the entire value.

For instance, if the original line was:

app\_path: {{ base\_path }}/foo

It should be written as:

app\_path: “{{ base\_path }}/foo”

Who knows how to set user or hosts of playbook with variable in ansible 1.4? Thanks.

---

<div class="post-metadata">

**Author:** ![rella.guo](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rella.guo](https://forum.ansible.com/u/rella.guo)\
**Post date:** [December 5, 2013, 6:36am UTC](https://forum.ansible.com/t/does-user-or-host-of-playbook-can-be-set-by-variable-in-version-1-4/14068/2 "2013-12-05T06:36:49Z")

</div>

I think I have resolved it. Using **"** {{ user }} **"** to replace $user.  
For hosts, using **"** {{ jboss\_hosts }}:{{ httpd\_hosts }}:!localhost.localdomain\*\*"\*\* to replace $jboss\_hosts:$httpd\_hosts:!localhost.localdomain.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 5, 2013, 1:45pm UTC](https://forum.ansible.com/t/does-user-or-host-of-playbook-can-be-set-by-variable-in-version-1-4/14068/3 "2013-12-05T13:45:17Z")

</div>

Exactly as it says in the message? 🙂

– Michael
