Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check VMware Tools version after OVA/OVF deployment without poweron #469

Merged
merged 12 commits into from
Jun 7, 2023
24 changes: 17 additions & 7 deletions common/collect_ovf_vm_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
ovf_vm_guest_bitness: ""
ovf_vm_hardware_config_file: 'ovf_deploy_vm_info.json'

- name: "Get VM info"
include_tasks: vm_get_vm_info.yml

- name: "Get all the VM hardwares info"
include_tasks: vm_get_config.yml

Expand All @@ -33,7 +30,7 @@
ovf_vm_hardware_config: >-
{{
ovf_vm_hardware_config |
combine({'Guest OS ID': vm_guest_id | default(''),
combine({'Guest OS ID': vm_config.config.guestId | default(''),
'Guest OS Version': vm_config.config.guestFullName | default(''),
'Hardware Version': vm_hardware_version | default(''),
'CPU Number': vm_config.config.hardware.numCPU | default(''),
Expand Down Expand Up @@ -153,12 +150,17 @@
ovf_vm_vmtools_info: >-
{{
ovf_vm_vmtools_info |
combine({'Version': vm_config.config.tools.toolsVersion | default(''),
combine({'Config Tools Version': vm_config.config.tools.toolsVersion | default(''),
'Install Type': vm_config.config.tools.toolsInstallType | default(''),
'Upgrade Policy': vm_config.config.tools.toolsUpgradePolicy | default(''),
'Sync Time with Host': vm_config.config.tools.syncTimeWithHost | default('')})
}}

- name: "Power on VM"
include_tasks: vm_set_power_state.yml
vars:
vm_power_state_set: 'powered-on'

- name: "Wait for VMware Tools running"
include_tasks: vm_wait_vmtools_status.yml
vars:
Expand All @@ -168,12 +170,12 @@
- name: "Get VM's guest info"
include_tasks: vm_get_guest_info.yml

- name: "Update VMware Tools version"
- name: "Get Guest Tools version"
ansible.builtin.set_fact:
ovf_vm_vmtools_info: >-
{{
ovf_vm_vmtools_info |
combine({'Version': guestinfo_vmtools_info })
combine({'Guest Tools Version': guestinfo_vmtools_info })
}}
when: guestinfo_vmtools_info

Expand Down Expand Up @@ -247,3 +249,11 @@
ansible.builtin.copy:
dest: "{{ ovf_vm_hardware_config_path }}/{{ ovf_vm_hardware_config_file }}"
content: "{{ [ovf_vm_hardware_config] | to_nice_json }}"

- name: "Check ddb.toolsVersion of open-vm-tools in OVA is expected"
ansible.builtin.assert:
that:
- ovf_vm_vmtools_info['Config Tools Version'] | string | length > 0 or vm_extra_config['guestinfo.vmtools.versionNumber'] | length > 0
- ovf_vm_vmtools_info['Config Tools Version'] | string in ['2147483647', vm_extra_config['guestinfo.vmtools.versionNumber']]
fail_msg: "The ddb.toolsVersion in OVA template is {{ ovf_vm_vmtools_info['Config Tools Version'] }}, not as expected '2147483647' or {{ vm_extra_config['guestinfo.vmtools.versionNumber'] }}."
success_msg: "The ddb.toolsVersion in OVA template is {{ ovf_vm_vmtools_info['Config Tools Version'] }}, which is as expected."
8 changes: 3 additions & 5 deletions linux/deploy_vm/deploy_vm_from_ova.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@
vars:
snapshot_name: "{{ base_snapshot_for_reconfig }}"

- name: "Power on VM"
include_tasks: ../../common/vm_set_power_state.yml
vars:
vm_power_state_set: 'powered-on'

- name: "Collect OVA configs"
include_tasks: "../../common/collect_ovf_vm_config.yml"
vars:
ovf_vm_hardware_config_path: "{{ current_test_log_folder }}"

- name: "Get VM info"
include_tasks: ../../common/vm_get_vm_info.yml

- name: "Try to get OS type from guest info"
include_tasks: get_ova_guest_os_type.yml
Expand Down
11 changes: 2 additions & 9 deletions windows/deploy_vm/deploy_vm_from_ova.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,14 @@
ansible.builtin.set_fact:
vm_exists: true

# Power on VM and wait for guest fullname reported by VMware tools
- name: "Power on VM"
include_tasks: ../../common/vm_set_power_state.yml
vars:
vm_power_state_set: "powered-on"

- name: "Get VM info"
include_tasks: ../../common/vm_get_vm_info.yml

# Get OVA deployed VM info
- name: "Collect hardware configs of the VM deployed from OVF"
include_tasks: ../../common/collect_ovf_vm_config.yml
vars:
ovf_vm_hardware_config_path: "{{ current_test_log_folder }}"

- name: "Get VM info"
include_tasks: ../../common/vm_get_vm_info.yml
# - include_tasks: ../../common/vm_get_ip_from_vmtools.yml

# Copy script ConfigureRemotingForAnsible.ps1 to guest OS
Expand Down