Ansible - Resolve "Encountered unknown tag"
by
Jeremy Canfield |
Updated: July 13 2023
| Ansible articles
Let's say you have a template file named my_file.j2.
/path/to/templates/my_file.j2
And let's say my_file.j2 contains the following.
{%Y}
And you have the following playbook which uses templates to copy my_file.j2 to /tmp/my_file.txt on each target server.
---
- hosts: all
tasks:
- name: copy my_file.j2 to /tmp/my_file.txt
template:
src: /path/to/templates/my_file.j2
dest: /tmp/my_file.txt
...
Running this play should return Encounted unknown tag 'Y' because {%Y} is built in jinja2 syntax.
Encounted unknown tag 'Y'
In this scenario, you can wrap {% raw %} and {% endraw %} around the {%Y} built in jinja2 syntax so that {%Y} is not interpreted as jinja2.
{% raw %}{%Y}{% endraw %}
Did you find this article helpful?
If so, consider buying me a coffee over at
Comments
July 23 2021 by Steve
This helped me out with an issue with the www.conf file of PHP-FPM which had %Y in the comments of some settings.