error: unexpected char u'_' for template action

I have one template file like that:

ErrorDocument 403 /customerror/$403_error_page

For ansible 1.4, I change the template to:

ErrorDocument 403 /customerror/{{ 403_error_page }}

Then I got the error:

fatal: [192.168.126.143] => {‘msg’: “file: /home/playbooks/templates/conf/mod.conf, line number: 15, error: unexpected char u’’ at 483", ‘failed’: True}
fatal: [192.168.126.143] => {‘msg’: ‘One or more items failed.’, ‘failed’: True, ‘changed’: False, ‘results’: [{‘msg’: "file: /home//playbooks/templates/conf/mod.conf, line number: 15, error: unexpected char u’
’ at 483”, ‘failed’: True}]}

Who knows the reason? Thanks.

Hi,

Not sure this is the cause, but a variable should always start with a letter
see http://www.ansibleworks.com/docs/playbooks_variables.html#id11

hth

fred

OK. This is a new constraint. If I use $foo format, it works well.
Anyway, thank you much very!

This is almost true.

Jinja2 variables should follow standard Python/programming language variable constraints.

You should definitely rename your variables, but if you technically need to access them by name you can still do so.

{{ hostvars[inventroy_hostname][“403_error_page”] }}

Will still allow you to get at a variable that doesn’t have a valid variable name.

In any case, you should rename your variables as $legacy variable syntax will be removed in 1.6.