【问题标题】:Ansible/yaml: If syntax inside the for syntaxAnsible/yaml:for 语法中的 if 语法
【发布时间】:2018-10-30 03:10:31
【问题描述】:

这可能吗? 我想决定将迭代哪个“dict”for循环。

{% for item, value in {% if source == "cde" %} abc.iteritems() {% else %} def.iteritems() {% endif %} %} item {% endfor %}

【问题讨论】:

    标签: yaml ansible-template


    【解决方案1】:

    我可以看到类似的东西:

    {% for item, value in abc.iteritems() if source == "cde" %}
        {{ item.value }}
    {% else %}
        {% for item, value in def.iteritems() %}
            {{ item.value }}
        {% endfor %}
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 2015-12-25
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多