Ansible when语句不应包括jinja2模板

Ansible when语句不应包括jinja2模板,ansible,jinja2,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 我认为可能是等效的 when: (((routes is defined) and ('celery' is in rou

我需要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

我认为可能是等效的

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

我认为可能是等效的

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

非常感谢。这是我以前的变体谢谢。这是我以前的变体=))