Ansible + jinja2 macro

Hi @all,

I am trying to use a macro in an ansible template:

{% macro logging(ltype) %}`
``

{% if ltype == 'fluentd' %}
logging:
  driver: 'fluentd'
  options:
    tag: "{{ app_name }}.{{ '{{' }}.Name{{ '}}' }}"
    labels: "mylabel"
{% endif %}
{% endmacro %}

...                                                                                                                   
   {{ logging('fluentd') }}                                                                                           
...

`

When I render it (template module), I am always getting

`

logging:
driver: ‘fluentd’
options:
tag: “test.{{.Name}}”
labels: “fhg.iam.appname,fhg.iam.hostname,fhg.iam.publicip,fhg.iam.privateip”

`

So apparently 'logging is indented right, but everything else just loses its indentation. Has anyone else got any similar problem?

Have you tried this to see if it removes the extra ident?

...                                                                                                                   
{{ logging('fluentd') }}                                                                                           
...

yes, thanks, funnily there is some logics behind that. The macro is like you would paste it at the spot. so, the first line is indented, and the others are not…

I don’t think so, at least in the examples I’ve seen so far, you can change user information in tables at will, but in fact you won’t be allowed to do so in version 3.6 + of mongo.

[

于宗洋

15911133389@163.com

](https://maas.mail.163.com/dashi-web-extend/html/proSignature.html?ftlId=1&name=%E4%BA%8E%E5%AE%97%E6%B4%8B&uid=15911133389%40163.com&iconUrl=http%3A%2F%2Fmail-online.nosdn.127.net%2Fsm27d9c4ca3f07df9ae8142c81e13e9c41.jpg&items=%5B%2215911133389%40163.com%22%5D)

签名由 网易邮箱大师 定制

On 11/6/2018 20:29,ProfHaseprofhase85@gmail.com wrote: