Skip to content

Commit

Permalink
[ocp4_workload_virt_roadshow_vmware] Using vcenter_folder_info instea…
Browse files Browse the repository at this point in the history
…d folder_moid

We are hitting the following bug:

ansible-collections/vmware.vmware_rest#324

This is a workaround till new version of the vmware.vmware_rest will be released
  • Loading branch information
agonzalezrh authored Sep 14, 2024
1 parent 1b43347 commit 6296667
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@
ansible.builtin.debug:
msg: "vcenter folder: {{ r_vcenter_folder }}"

# Bug: https://github.com/ansible-collections/vmware.vmware_rest/issues/324
# - name: Set folder ID fact
# ansible.builtin.set_fact:
# _ocp4_workload_virt_roadshow_vmware_vcenter_folder_id: >-
# {{ lookup('vmware.vmware_rest.folder_moid',
# '/' + vcenter_datacenter + '/vm/Workloads/' + _ocp4_workload_virt_roadshow_vmware_vcenter_folder,
# **_ocp4_workload_virt_roadshow_vmware_connection_args) }}
# retries: 10
# delay: 15
# until: _ocp4_workload_virt_roadshow_vmware_vcenter_folder_id | length > 0
#
- name: Get folder information
vmware.vmware_rest.vcenter_folder_info:
type: VIRTUAL_MACHINE
names:
- "{{ _ocp4_workload_virt_roadshow_vmware_vcenter_folder }}"
register: r_folder_info

- name: Set folder ID fact
ansible.builtin.set_fact:
_ocp4_workload_virt_roadshow_vmware_vcenter_folder_id: >-
{{ lookup('vmware.vmware_rest.folder_moid',
'/' + vcenter_datacenter + '/vm/Workloads/' + _ocp4_workload_virt_roadshow_vmware_vcenter_folder,
**_ocp4_workload_virt_roadshow_vmware_connection_args) }}
retries: 10
delay: 5
until: _ocp4_workload_virt_roadshow_vmware_vcenter_folder_id | length > 0
set_fact:
_ocp4_workload_virt_roadshow_vmware_vcenter_folder_id: "{{ r_folder_info.value[0].folder }}"

- name: Create VMs
environment:
Expand All @@ -34,7 +46,7 @@
VMWARE_PASSWORD: "{{ vcenter_password }}"
VMWARE_VALIDATE_CERTS: "{{ ocp4_workload_virt_roadshow_vmware_enable_cert_validation }}"
vmware.vmware_rest.vcenter_vmtemplate_libraryitems:
name: "{{ vm.name }}{{ _ocp4_workload_virt_roadshow_vmware_vcenter_vmname_suffix }}"
name: "{{ vm.name }}"
library: '{{ _ocp4_workload_virt_roadshow_vmware_template_library_id }}'
template_library_item: "{{ (_ocp4_workload_virt_roadshow_vmware_templates | selectattr('name', 'equalto', vm.template + '-l') | first).id }}"
placement:
Expand All @@ -46,7 +58,6 @@
powered_on: false
retries: 5
delay: 10
until: r_vmc_instance is success
loop: "{{ ocp4_workload_virt_roadshow_vmware_vms }}"
loop_control:
loop_var: vm
Expand Down

0 comments on commit 6296667

Please sign in to comment.