set_fact with default value of type string

I know I can define the variable previous to this, but I am wondering if I can combine setting a variable with a default value within set_fact. If possible, I wonder if my syntax is wrong (likely)? I can’t seem to find much documentation on this. If you have a link to this answer in the docs, I would like to review it, but apparently I am not using the right keywords in my search.

Basically, I wish to have the handler_name set to Networking unless my major version is 8. If that is the case then I want it set to: Network Manager

`

  • set_fact:
    handler_name: "{{ ‘Network Manager’ | default(‘Networking’) }} "
    when: ansible_distribution_major_version == 8

`

- set_fact:
     handler_name: "{{ 'Network Manager' if ansible_distribution_major_version == 8 else 'Networking' }}"

or

- set_fact:
     handler_name: "{{ (ansible_distribution_major_version == 8) | ternary('Network Manager', ''Networking') }}"

Which one to use comes down to personal preference.

Wow, I was really off. Thanks Kai!