Setting Variables Conditionally

I need to set some variables that are the same no matter the client, and other variables need to be set conditionally based on values from Ansible facts. Basically I need an if/else case statement. What is the correct way to do this?

Some simple examples can be found here (http://docs.ansible.com/ansible/latest/playbooks_conditionals.html#conditionals) but this doesn’t cover else conditions, and if I remove the second instance of VAR4, and put in condition that is not met, it still sets VAR4, when the match doesn’t exist, so it seems like the “when” is not being evaluated.

some ways to do this would be

using filters (clean way)
   set_fact:
        myvar: "{{ (ansible_os_family == 'RedHat') | ternary(100,200) }}"

or same thing via jinja conditionals

{{ 100 if ansible_os_family == 'RedHat' else 200 }}

with some 'or's

    {{ 100 if ansible_os_family == 'RedHat' or ansible_user_id ==
'vagrant' else 200 }}

This seems to be working, but is there a more readable way to write this?

size: “{{ 300 if 'string1’ in ansible_fact or ‘string_2’ in ansible_fact or ‘string_3’ in ansible_fact or ‘string_4’ in ansible_fact else 100 if ‘string_5’ in ansible_fact or ‘string_6’ in ansible_fact or ‘string_7’ in ansible_fact else 200 if ‘string_8’ in ansible_fact }}”