ANSIBLE Resolve Inventory Variable in Jinja2 for Block

Viewed 47

I've following dictionary

APPLICATIONS:
  - Name: "APP_01"
    KurzBez: "APP_01"
    BRANCH_LIST_HOST01: ["000"]
    BRANCH_LIST_HOST02: ["AAA", "BBB", "CCC"]

  - Name: "APP_02"
    KurzBez: "APP_02"
    BRANCH_LIST_HOST01: ["111"]
    BRANCH_LIST_HOST02: ["FFF", "DDD", "JJJ"]

And try to resolve the dic using jinja2 templating, but I can't access inventory_hostname_short within the jinja for block.

{% for application in APPLICATIONS %}
{% for branch in application.BRANCH_LIST_{{inventory_hostname_short}} %}
some text for {{branch}}
{% endfor %}
{% endfor %}

I've no idea how to fix that problem. Any ideas?

0 Answers
Related