Jinja2 template loop with JSON

Hello all,

I am a Network Engineer and Ansible is relative new for me.

At the moment I am trying to build a template with “JSON” as source. See below.

The template should do the follwing (hopefully you get the idea).
I am struggling, how can i get the items in the list “INT_LIST” ?
Can someone point my to a good sample or documentation.

TIA
Juergen

Hello all,

I am a Network Engineer and Ansible is relative new for me.

At the moment I am trying to build a template with "JSON" as source. See below.

The template should do the follwing (hopefully you get the idea).
I am struggling, how can i get the items in the list "INT_LIST" ?
Can someone point my to a good sample or documentation.

TIA
Juergen

Hello Juergen,

this should do the trick:

{% for item in host.INT_LIST %}

I suggest to pick a different loop variable name as "item" is the standard one
in Jinja.

Regards
         Racke

Hello Juergen,

this should do the trick:

{% for item in host.INT_LIST %}

I suggest to pick a different loop variable name as “item” is the standard one
in Jinja.

Regards
Racke

Hello Racke,

this was the missing part. :slight_smile:

Thank you so much!
Regards from Switzerland
Juergen