Thank you very much, I worked, that was exactly what I needed.

2015-12-29 11:54 GMT-03:00 Matt Martz <[email protected]>:

> What you need to do is tell jinja2 that the value should not be parsed.
> To do this you can use `{% raw %} ... {% endraw %}` such as:
>
> api_log_format: "{% raw %}[%(asctime)s] {%(pathname)s:%(lineno)d}
> %(levelname)s - %(message)s{% endraw %}"
>
> On Tue, Dec 29, 2015 at 7:42 AM, Guido <[email protected]> wrote:
>
>>
>>
>> 2015-12-29 10:41 GMT-03:00 Guido Accardo <[email protected]>:
>>
>>> Hi everyone,
>>>
>>>    I'm trying to put a string by replacing a macro in a template but the
>>> problem is that the string itself it's being interpreted as a macro and I
>>> need to avoida that. Here are config vars and the template:
>>>
>>> vars.yml:
>>> log_format: "[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s -
>>> %(message)s"
>>> expire: 1000
>>>
>>> template (setting.py):
>>> formatter = logging.Formatter("{{ api_log_format }}")
>>> expire = {{expire}}
>>>
>>> When I execute the playbook I'm getting the following error:
>>>
>>> {'msg': 'AnsibleError: ERROR! Failed to template [%(asctime)s]
>>> {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s: ERROR! template
>>> error while templating string: tag name expected', 'failed': True}
>>>
>>> If I change {%(pathname)s:%(lineno)d}  with for example
>>> [%(pathname)s:%(lineno)d] the problem it's solved and the playbook
>>> continues but I can't do that because it's a developers request that the {
>>> and } exists in the log format.
>>>
>>> Is there any way that I could tell ansible to ignore that specific line?
>>>
>>> Any other idea?
>>>
>>> I'm using ansible v1.9.2
>>>
>>> Thanks!
>>>
>>
>> There is a typo in my first email,
>>
>> This line log_format: "[%(asctime)s] {%(pathname)s:%(lineno)d}
>> %(levelname)s - %(message)s"
>>
>> should be
>>
>> api_log_format: "[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s -
>> %(message)s"
>>
>>
>> Sorry
>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Ansible Project" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/ansible-project/92lSFwtyYK0/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/9bb7958d-9224-4ff0-a3f3-54dbf66605c0%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/9bb7958d-9224-4ff0-a3f3-54dbf66605c0%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> -- Guido Accardo --
>> "... What we know is a drop, what we ignore is the ocean ..." Isaac Newton
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAAjwECFN6T1G9%3D71mTuFdyk2wWg3BSvg_4C4oBtKb-bATSuMqg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAAjwECFN6T1G9%3D71mTuFdyk2wWg3BSvg_4C4oBtKb-bATSuMqg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/92lSFwtyYK0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAD8N0v8CpAdW10bVU%2B63uAx9P-wURj9Y4FUYEH4gYYSuCkcwCA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAD8N0v8CpAdW10bVU%2B63uAx9P-wURj9Y4FUYEH4gYYSuCkcwCA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- Guido Accardo --
"... What we know is a drop, what we ignore is the ocean ..." Isaac Newton

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAjwECH0rHOjufH-1ey%3Ddr8YDQs8SAoS4gpezYNGiJvh-CXSxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to