I have the following code
- set_fact:
MY_HOSTNAME: "SOME VALUE"
MY_SERVER: "00.00.00.00"
- name: Get MY server
set_fact:
MY_SERVER: "{{ groups[MY_HOSTNAME][0] }}"
when: groups[MY_HOSTNAME] is defined
In the above code, groups[MY_HOSTNAME]
is an array. What is the best way to check that groups[MY_HOSTNAME]
is defined and also that it is not empty
If it is either of that I want the value 00.00.00.00
to be assigned to MY_SERVER