-
Notifications
You must be signed in to change notification settings - Fork 328
/
main.yml
156 lines (140 loc) · 5.36 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Test code for the vmware_vm_config_option module.
# Copyright: (c) 2021, VMware, Inc. All Rights Reserved.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
- when: vcsim is not defined
block:
- name: get list of config option keys from ESXi host
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_hardware_versions: true
register: config_option_keys_1
- debug:
var: config_option_keys_1
- name: get list of config option keys from cluster
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
cluster_name: "{{ ccr1 }}"
get_hardware_versions: true
register: config_option_keys_2
- debug:
var: config_option_keys_2
# Ignore errors due to there is known issue on vSphere 7.0.x
# https://github.com/vmware/pyvmomi/issues/915
- name: get list of supported guest IDs from ESXi host
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_guest_os_ids: true
register: guest_ids_1
ignore_errors: true
- debug:
var: guest_ids_1
- name: check guest ID list returned when task not failed
assert:
that:
- "'instance' in guest_ids_1"
- guest_ids_1.instance | length != 0
when:
- "'failed' in guest_ids_1"
- not guest_ids_1.failed
- block:
# Ignore errors due to there is known issue on vSphere 7.0.x
# https://github.com/vmware/pyvmomi/issues/915
- name: get list of supported guest IDs from ESXi host with config option key
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_guest_os_ids: true
hardware_version: "{{ config_option_keys_1['instance']['Supported hardware versions'][0] }}"
register: guest_ids_2
ignore_errors: true
- debug:
var: guest_ids_2
- name: check guest ID list returned when task not failed
assert:
that:
- "'instance' in guest_ids_2"
- guest_ids_2.instance | length != 0
when:
- "'failed' in guest_ids_2"
- not guest_ids_2.failed
when:
- "'instance' in config_option_keys_1"
- "'Supported hardware versions' in config_option_keys_1['instance']"
# Ignore errors due to there is known issue on vSphere 7.0.x
# https://github.com/vmware/pyvmomi/issues/915
- name: get dict of recommended configs for specified guest ID from ESXi host
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_config_options: true
guest_id: "rhel6_64Guest"
register: recommended_configs
ignore_errors: true
- debug:
var: recommended_configs
- name: check guest ID list returned when task not failed
assert:
that:
- "'instance' in recommended_configs"
- recommended_configs.instance | length != 0
when:
- "'failed' in recommended_configs"
- not recommended_configs.failed
- name: get list of config option keys by connecting to ESXi host
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ esxi_hosts[0] }}"
username: "{{ esxi_user }}"
password: "{{ esxi_password }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_hardware_versions: true
register: config_option_keys_3
- debug:
var: config_option_keys_3
- name: get list of supported guest IDs by connecting to ESXi host with config option key
community.vmware.vmware_vm_config_option:
validate_certs: false
hostname: "{{ esxi_hosts[0] }}"
username: "{{ esxi_user }}"
password: "{{ esxi_password }}"
esxi_hostname: "{{ esxi_hosts[0] }}"
get_guest_os_ids: true
hardware_version: "{{ config_option_keys_3['instance']['Supported hardware versions'][2] }}"
register: guest_ids_3
ignore_errors: true
- debug:
var: guest_ids_3
- name: check guest ID list returned when task not failed
assert:
that:
- "'instance' in guest_ids_3"
- guest_ids_3.instance | length != 0
when:
- "'failed' in guest_ids_3"
- not guest_ids_3.failed