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

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.

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.

Exactly as it says in the message? :slight_smile:

– Michael