when语句不应包含jinja2模板

时间:2019-05-20 10:24:58

标签: ansible jinja2

在when语句中我需要一个if条件。我该怎么办?

现在看起来像这样:

when: {% if routes is defined %}'celery' is in routes{% else %}inventory_hostname in groups['celery']{% endif %} and deploy_state.colors.celery is defined

1 个答案:

答案 0 :(得分:0)

我认为可能是

when: (((routes is defined) and ('celery' is in routes)) or
       (inventory_hostname in groups['celery'])) and
       (deploy_state.colors.celery is defined)