Complex conditionnal when statement - second part is not evaluated

Hello everyone !

I’ve got a small problem when trying to evaluate this task :

  • name: Testing port 80 - 443 - 8443 on server_x
    wait_for: host=server_x port={{item}} timeout=1
    with_items:
  • 80
  • 443
  • 8443
    when: (sg_building == “TIGERY” and sg_marley_environment == “DEV” and sg_building is defined and sg_marley_environment is defined) or (specified_building == “TIGERY” and specified_environment == “DEV” and specified_building is defined and specified_environment is defined)

sg_building and sg_marley_environement are populated from the dynamic inventory.
specified building and specified_environement are passed to the playbook via extra-vars (-e option with the ansible-playbook command)

It looks like only the first part of the condition (before the “or”) is evaluated : do you have any idea why ? (it’s skipping if the condition is after the “or”)

Thank you for help !

Regards,
Samy Girard