Debian Codegraph @

ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/tasks/main.yml

raw
1 # Test code for the vmware_guest_info module.
2 # Copyright: (c) 2022, Mario Lenz <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 - import_role:
6 name: prepare_vmware_tests
7 vars:
8 setup_attach_host: true
9
10 - name: Get info from an ESXi host
11 community.vmware.vmware_host_facts:
12 validate_certs: false
13 hostname: "{{ vcenter_hostname }}"
14 username: "{{ vcenter_username }}"
15 password: "{{ vcenter_password }}"
16 esxi_hostname: "{{ esxi1 }}"
17 register: host_facts_0001
18
19 - debug:
20 var: host_facts_0001
21
22 - assert:
23 that:
24 - host_facts_0001 is defined
25
26 # https://github.com/ansible-collections/community.vmware/issues/184#issuecomment-630950107
27 - name: Get info from an ESXi host that is offline / disconnected / shut down
28 block:
29 - name: Disconnect ESXi host
30 vmware.vmware.esxi_connection:
31 validate_certs: false
32 hostname: "{{ vcenter_hostname }}"
33 username: "{{ vcenter_username }}"
34 password: "{{ vcenter_password }}"
35 datacenter: '{{ dc1 }}'
36 esxi_host_name: "{{ esxi1 }}"
37 state: disconnected
38
39 - name: Give the ESXi host time to disconnect
40 ansible.builtin.pause:
41 minutes: 1
42
43 - name: Get info from an ESXi host that is disconnected
44 community.vmware.vmware_host_facts:
45 validate_certs: false
46 hostname: "{{ vcenter_hostname }}"
47 username: "{{ vcenter_username }}"
48 password: "{{ vcenter_password }}"
49 esxi_hostname: "{{ esxi1 }}"
50 register: host_facts_0002
51
52 - debug:
53 var: host_facts_0002
54
55 - assert:
56 that:
57 - host_facts_0002 is defined
58 always:
59 - name: Reconnect ESXi host
60 vmware.vmware.esxi_connection:
61 validate_certs: false
62 hostname: "{{ vcenter_hostname }}"
63 username: "{{ vcenter_username }}"
64 password: "{{ vcenter_password }}"
65 datacenter: '{{ dc1 }}'
66 esxi_host_name: "{{ esxi1 }}"
67 state: connected