|
6 | 6 | hosts: localhost |
7 | 7 | gather_facts: false |
8 | 8 | tasks: |
9 | | - - include_tasks: get_ansible_info.yml |
10 | | - - include_tasks: set_default_variables.yml |
| 9 | + - name: "Get ansible info" |
| 10 | + include_tasks: get_ansible_info.yml |
11 | 11 |
|
12 | | - # Create this test run log files path |
13 | | - - include_tasks: create_local_log_path.yml |
| 12 | + - name: "Set default variables" |
| 13 | + include_tasks: set_default_variables.yml |
14 | 14 |
|
15 | | - # Check and initialize variables for VM settings |
16 | | - - include_tasks: check_testing_vars.yml |
| 15 | + - name: "Create this test run log files path" |
| 16 | + include_tasks: create_local_log_path.yml |
17 | 17 |
|
18 | | - # Set hostname of Ansible module connecting |
19 | | - - include_tasks: ../common/set_vmware_module_hostname.yml |
| 18 | + - name: "Check and initialize variables for VM settings" |
| 19 | + include_tasks: check_testing_vars.yml |
| 20 | + |
| 21 | + - name: "Set hostname of Ansible module connecting" |
| 22 | + include_tasks: ../common/set_vmware_module_hostname.yml |
| 23 | + |
| 24 | + - name: "Check VM existence" |
| 25 | + include_tasks: ../common/vm_check_exist.yml |
20 | 26 |
|
21 | | - # Check VM existence |
22 | | - - include_tasks: ../common/vm_check_exist.yml |
23 | 27 | - name: "Check VM '{{ vm_name }}' does not exist" |
24 | 28 | ansible.builtin.assert: |
25 | 29 | that: |
|
34 | 38 | fail_msg: "VM '{{ vm_name }}' doesn't exist. Please set new_vm to True to deploy the VM or provide an existing VM name." |
35 | 39 | when: new_vm is undefined or not new_vm | bool |
36 | 40 |
|
37 | | - # Get VM related info if testing on existing VM |
38 | | - - include_tasks: ../common/vm_get_vm_info.yml |
39 | | - when: vm_exists is defined and vm_exists |
40 | | - - name: Set fact of the VM datastore path |
41 | | - ansible.builtin.set_fact: |
42 | | - vm_datastore_path: "/vmfs/volumes/{{ datastore }}" |
43 | | - - name: Display the datatore path of VM files |
44 | | - ansible.builtin.debug: var=vm_datastore_path |
45 | | - |
46 | | - # Get vCenter and ESXi version info |
47 | | - - include_tasks: ../common/vcenter_get_version_build.yml |
| 41 | + - name: "Get vCenter Server version and build" |
| 42 | + include_tasks: ../common/vcenter_get_version_build.yml |
48 | 43 | when: vcenter_is_defined is defined and vcenter_is_defined |
49 | | - - include_tasks: ../common/esxi_get_version_build.yml |
| 44 | + |
| 45 | + - name: "Get ESXi version and build" |
| 46 | + include_tasks: ../common/esxi_get_version_build.yml |
50 | 47 |
|
51 | 48 | - name: "ESXi version {{ esxi_version }} is not supported" |
52 | 49 | ansible.builtin.fail: |
53 | 50 | msg: "This project only supports guest OS validation on ESXi 6.5 or later" |
54 | 51 | when: esxi_version == 'N/A' or esxi_version is version('6.5.0', '<') |
55 | 52 |
|
56 | | - # Get ESXi server model info |
57 | | - - include_tasks: ../common/esxi_get_model.yml |
| 53 | + - name: "Get ESXi server model info" |
| 54 | + include_tasks: ../common/esxi_get_model.yml |
58 | 55 |
|
59 | 56 | - name: "Set ESXi server default shell to /bin/sh on {{ esxi_version }}" |
60 | 57 | ansible.builtin.set_fact: |
|
67 | 64 | esxi_shell: "/bin/supershell" |
68 | 65 | when: esxi_version is version('8.0.0', '>=') |
69 | 66 |
|
70 | | - # Add esxi host into memory inventory |
71 | | - - include_tasks: ../common/add_host_in_memory_inventory.yml |
| 67 | + - name: "Cleanup snapshots and get VM related information" |
| 68 | + block: |
| 69 | + - name: "Not cleanup old snapshot by default" |
| 70 | + ansible.builtin.set_fact: |
| 71 | + cleanup_old_snapshots: false |
| 72 | + when: cleanup_old_snapshots is undefined |
| 73 | + |
| 74 | + - name: "Revert and cleanup existing snapshots on existing VM if required" |
| 75 | + include_tasks: ../common/vm_cleanup_snapshot.yml |
| 76 | + |
| 77 | + - name: "Get VM power state" |
| 78 | + include_tasks: ../common/vm_get_power_state.yml |
| 79 | + |
| 80 | + - name: "Power on VM" |
| 81 | + include_tasks: ../common/vm_set_power_state.yml |
| 82 | + vars: |
| 83 | + vm_power_state_set: "powered-on" |
| 84 | + when: vm_power_state_get == "poweredOff" |
| 85 | + |
| 86 | + - name: "Check VM settings" |
| 87 | + include_tasks: check_vm_settings.yml |
| 88 | + |
| 89 | + - name: "Get existing VM info" |
| 90 | + include_tasks: ../common/vm_get_vm_info.yml |
| 91 | + when: vm_exists is defined and vm_exists |
| 92 | + |
| 93 | + - name: Set fact of the VM datastore path |
| 94 | + ansible.builtin.set_fact: |
| 95 | + vm_datastore_path: "/vmfs/volumes/{{ datastore }}" |
| 96 | + |
| 97 | + - name: Display the datatore path of VM files |
| 98 | + ansible.builtin.debug: var=vm_datastore_path |
| 99 | + |
| 100 | + - name: "Add esxi host into memory inventory" |
| 101 | + include_tasks: ../common/add_host_in_memory_inventory.yml |
72 | 102 | vars: |
73 | 103 | add_host_in_memory_inventory_ip: "{{ esxi_hostname }}" |
74 | 104 | add_host_in_memory_inventory_gp: "esxi" |
|
79 | 109 | add_host_in_memory_inventory_remote_tmp: "{{ vm_datastore_path }}" |
80 | 110 | add_host_in_memory_inventory_shell: "{{ esxi_shell }}" |
81 | 111 |
|
82 | | - # Enable guest IP hack on ESXi host to get VM IP address when |
83 | | - # there is no VMware tools installed or VMware tools is not up |
84 | | - - include_tasks: ../common/esxi_enable_guest_ip_hack.yml |
85 | | - |
86 | | - # For existing VM |
87 | | - - block: |
88 | | - - name: "Not cleanup old snapshot by default" |
89 | | - ansible.builtin.set_fact: |
90 | | - cleanup_old_snapshots: false |
91 | | - when: cleanup_old_snapshots is undefined |
92 | | - |
93 | | - # Cleanup existing snapshots of existing VM if required |
94 | | - - include_tasks: ../common/vm_cleanup_snapshot.yml |
95 | | - when: cleanup_old_snapshots | bool |
96 | | - |
97 | | - # Check VM settings |
98 | | - - include_tasks: check_vm_settings.yml |
99 | | - when: (new_vm is undefined) or (not new_vm | bool) |
| 112 | + - name: "Enable guest IP hack on ESXi host to get VM IP address when there is no VMware tools installed or VMware tools is not up" |
| 113 | + include_tasks: ../common/esxi_enable_guest_ip_hack.yml |
0 commit comments