# Playbook variables, documentation confusing

**URL:** <https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965>\
**Category:** Ansible Project\
**Created:** [June 15, 2013, 2:13pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965 "2013-06-15T14:13:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_f\_krafft](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@martin\_f\_krafft](https://forum.ansible.com/u/martin_f_krafft)\
**Post date:** [June 15, 2013, 2:13pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/1 "2013-06-15T14:13:07Z")

</div>

Dear list,

I am using the tip of Ansible development:

&nbsp;&nbsp;% ansible-playbook --version  
&nbsp;&nbsp;ansible-playbook 1.3 (devel 0bd5fe9951) last updated 2013/06/15 16:06:49 (GMT +200)

On [http://www.ansibleworks.com/docs/playbooks.html](http://www.ansibleworks.com/docs/playbooks.html), I read the  
following paragraph (under "Vars section"):

&nbsp;&nbsp;These variables can be used later in the playbook like this:

&nbsp;&nbsp;&nbsp;&nbsp;$varname or ${varname} or {{ varname }}

&nbsp;&nbsp;If you ever want to do anything complex like uppercasing a string,  
&nbsp;&nbsp;{{ varname }} is best, as it uses the Jinja2 templating engine. It  
&nbsp;&nbsp;is a good idea to get in the habit of using this form most of the  
&nbsp;&nbsp;time when the output is to be a string.

However, if I try to use the Jinja2-syntax in a playbook, I get an  
error:

&nbsp;&nbsp;% ansible-playbook motd.yml  
&nbsp;&nbsp;ERROR: Syntax Error while loading YAML script, motd.yml  
&nbsp;&nbsp;Note: The error may actually appear before this position: line 6, column 16

&nbsp;&nbsp;&nbsp;&nbsp;- role: motd  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;override: {{motd.override}}

While trying to figure out what is going on, I found that  
docsite/playbooks.html severly differs from the online  
documentation. Specifically, under "Vars section", there is no  
mention of the ability to use the Jinja2-syntax in a playbook.

What's going on? Am I wrong in assuming that docsite/\* in the source  
checkout should be /more/ up-to-date than the website?

I have also set

&nbsp;&nbsp;legacy\_playbook\_variables=no

in ~/.ansible.cfg, but I can use $variable just like before, without  
any problems. In fact, that's the only way to access a variable.

Any clues?

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [June 15, 2013, 2:21pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/2 "2013-06-15T14:21:14Z")

</div>

Not sure if you can use the override with rolls there, but guess you need to indent it with 2 spaces.

---

<div class="post-metadata">

**Author:** ![martin\_f\_krafft](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@martin\_f\_krafft](https://forum.ansible.com/u/martin_f_krafft)\
**Post date:** [June 15, 2013, 2:33pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/3 "2013-06-15T14:33:28Z")

</div>

also sprach Vincent Van der Kussen \<vincent.vanderkussen@gmail.com\> [2013.06.15.1621 +0200]:

> Not sure if you can use the override with rolls there,

Yes, I can, and it works. The problem is with the expansion of  
variables.

> but guess you need to indent it with 2 spaces.

Nope, that would be invalid syntax. The syntax is fine.

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [June 15, 2013, 2:40pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/4 "2013-06-15T14:40:54Z")

</div>

I was guessing because i saw this

% ansible-playbook motd.yml  
ERROR: Syntax Error while loading YAML script, motd.yml

---

<div class="post-metadata">

**Author:** ![martin\_f\_krafft](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@martin\_f\_krafft](https://forum.ansible.com/u/martin_f_krafft)\
**Post date:** [June 15, 2013, 3:23pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/5 "2013-06-15T15:23:26Z")

</div>

also sprach Vincent Van der Kussen \<vincent.vanderkussen@gmail.com\> [2013.06.15.1640 +0200]:

> I was guessing because i saw this
> 
> &nbsp;&nbsp;% ansible-playbook motd.yml  
> &nbsp;&nbsp;ERROR: Syntax Error while loading YAML script, motd.yml

That was a good spot. It turs out that

&nbsp;&nbsp;- role: test  
&nbsp;&nbsp;&nbsp;&nbsp;override: {{override}}

is a syntax error, due to the {} characters. Doing this:

&nbsp;&nbsp;- role: test  
&nbsp;&nbsp;&nbsp;&nbsp;override: '{{override}}'

instead works.

And it makes sense when you think of it. python-yaml parses the YAML  
file and only then does Ansible run the data through Jinja2 for  
interpolation. Since {} are reserved characters in YAML, they need  
to be quoted.

Thanks, Vincent, your hawk eye and patience allowed me to figure  
this out.

This still leaves the differences between the in-checkout  
documentation and the website…

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 15, 2013, 3:38pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/6 "2013-06-15T15:38:50Z")

</div>

The website was normally refreshed manually, a certain lag was expected. That said, recently there have been major changes in location and style so not sure if /docsite is still relevant.

---

<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:** [June 15, 2013, 4:19pm UTC](https://forum.ansible.com/t/playbook-variables-documentation-confusing/12965/7 "2013-06-15T16:19:44Z")

</div>

docsite is still quite active in the repository and is the source of all documentation still.

Don’t worry, nothing has changed!

We just haven’t pushed updates every single day because of being engaged with AnsibleFest!
