For 2.0 How to test if variable set to null in when clause

pre 2.0

set_fact:
uberHost: “{{ ansible_ssh_host }}”
when: ansible_ssh_host is defined

set fact:
uberHost: “{{ inventory_hostname }}”
when: ansible_ssh_host is not defined

Post 2.0, changed to use ansible_host
uberHost is always getting set to null
ansible_host is defined and set to null even when it’s not present in the inventory file
I haven’t figured out how to test to see if ansible_host is null in a when clause.

It should be enough to just check:

when: ansible_ssh_host

However it may be good to come at it from a little different direction and use something like:

set_fact:
uberHost: “{{ ansible_ssh_host|default(inventory_hostname, True) }}”

The True in default() will tell jinja2 to use pythons truthyness checks, so an empty string evaluates as false as well.

you can even chain them and make it future proof
set_fact:
    uberHost: "{{
ansible_host|default(ansible_ssh_host|default(inventory_hostname,
True), True) }}"

when: ansible_host still caused the set_fact to execute when it was not present / null

However, the other suggestions worked great, thanks!