Not exactly based on the variables, but I use this to find the datacenter
in the vCenter (in my case I have only one datacenter per vCenter so it
works)
- name: Gather information about all datacenters in vCenter
community.vmware.vmware_datacenter_info:
hostname: "{{ hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: "{{ false}}"
delegate_to: localhost
register: datacenterInfo
#- name: Display datacenter Info
#ansible.builtin.debug:
#msg: "{{ datacenterInfo.datacenter_info[0].name }}"
- name: set Fact - datacenter
set_fact:
datacenter: "{{ datacenterInfo.datacenter_info[0].name }}"
Hope this helps.
Warm Regards,
Abhi
On Friday 17 May 2024 at 23:02:18 UTC+2 Brian Coca wrote:
Also:
vars:
vcenter_datacenter: '{{ vcenter_hostname ==
"vcenter1"|ternary("First", vcenter_hostname ==
"vcenter2"|ternary("datacenter1", "datacenter2")) }}' Dataceenter
but i would do this:
vars:
DCS:
vcenter1: First
vcenter2: datacenter1
vcenter_datacenter: '{{ DCS[vcenter_hostname]|default("datacenter2")
}}' Datacenter
--
----------
Brian Coca (he/him/yo)
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4408f066-5195-468d-88a8-89e0a4b5b365n%40googlegroups.com.