On 28.01.2019 22:41, John Harmon wrote:
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.
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bdc40a6a05c2e43bc4b7bbbbceac6f81%40olstad.com.
For more options, visit https://groups.google.com/d/optout.