jinja2: escaping special chars

i want to generate a config for syslogd from template. as there are some “special” chars in the config, the ‘*’ char in this case, ansible has some problems to run the template.
how to i tell ansible/jinja2 to treat the star as an literal?

error:

AnsibleError: template error while templating string: expected token ‘end of statement block’, got ‘*’. String: # {{ ansible_managed }}

template:

`

{{ ansible_managed }}

auth.info /var/log/syslog/auth rotate compress size 10m files 10
.info /var/log/syslog/messages rotate compress size 10m files 10
local2.
/var/log/syslog/sudo rotate compress size 10m files 10
{% if ( (inventory_lparname not in groups[‘HA_HOST’] | default()) and
(inventory_lparname not in groups[‘DMZ_HOST’] | default()) ):
*.info @1.2.3.4
{% endif %}
{% if inventory_lparname in groups[‘HA_HOST’] | default() %}

HACMP Config

*.info @1.2.3.4

PowerHA SystemMirror Critical Messages

local0.crit /dev/console

PowerHA SystemMirror Informational Messages

local0.info /var/hacmp/adm/cluster.log rotate size 1m files 8

PowerHA SystemMirror Messages from Cluster Scripts

user.notice /var/hacmp/adm/cluster.log rotate size 1m files 8

PowerHA SystemMirror Messages from Cluster Daemons

daemon.notice /var/hacmp/adm/cluster.log rotate size 1m files 8

caa.info /var/adm/ras/syslog.caa rotate size 1m files 10
{% endif %}
{% if (inventory_lparname in groups[‘DMZ_HOST’] | default())
*.info @1.2.3.4
{% endif %}
{% if ( (‘some_host’ in ansible_hostname) or
(‘some_host’ in ansible_hostname) or
(‘some_host’ in ansible_hostname) or
(‘some_host’ in ansible_hostname) or
(‘some_host’ in ansible_hostname) or
(‘some_host’ in ansible_hostname) ):

Trusted Logging

*.info /dev/vlog0
{% endif %}

ASO log configuration

aso.notice /var/log/aso/aso.log rotate size 128k time 7d
aso.info /var/log/aso/aso_process.log rotate size 1024k
aso.debug /var/log/aso/aso_debug.log rotate size 8m compress

mail.debug /var/log/syslog/mail rotate time 7d files 4 compress

`

Thats the default.

Your problem is that your first and last if statement is missing the closing tag %}, you have used a colon.

hmm…added the missing tags…now another error comes up.

AnsibleError: template error while templating string: unexpected ‘.’. String: # {{ ansible_managed }}

Did you also remove the colon and checked all the if's?
I see there is also another one that is wrong.

If yes you need to post the file again since you know have done changes to it.