[ansible-project] Re: Ansible + jinja2 macro

2018-11-06 Thread ProfHase
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...

Am Donnerstag, 1. November 2018 18:16:03 UTC+1 schrieb Tony Chia:
>
> Have you tried this to see if it removes the extra ident?
>
> ...   
> 
> {{ logging('fluentd') }}  
>  
> ...
>
>
> On Wednesday, October 31, 2018 at 3:39:22 AM UTC-7, ProfHase wrote:
>>
>> 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?
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c715437c-dfb1-4fd9-a34c-52202f36b8c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible + jinja2 macro

2018-11-01 Thread Tony Chia
Have you tried this to see if it removes the extra ident?

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


On Wednesday, October 31, 2018 at 3:39:22 AM UTC-7, ProfHase wrote:
>
> 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?
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/175e9a8b-dba9-4277-b7a8-0adf4be11b08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.