-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_vms.yml
43 lines (38 loc) · 1.35 KB
/
get_vms.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
---
#Notes 8/12/20
# 1) Engineer removed vm_name, vm_cluster, vm_folder
# 2) Used vm_ware_info with folder module and direct path.
# 3) used forcebasic_auth: yes
# 4) used validate_certs: no
- name: Gather all registered virtual machines
hosts: all
vars:
ansible_python_interpreter: "/usr/bin/env python3"
tasks:
- name: Login into vCenter and get cookies
uri:
url: https://{{ vcenter_hostname }}/rest/com/vmware/cis/session
force_basic_auth: yes
validate_certs: no
method: POST
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
register: login
- name: Get all hosts from vCenter using cookies from last task
uri:
url: https://{{ vcenter_hostname }}/rest/vcenter/host
force_basic_auth: yes
validate_certs: no
headers:
Cookie: "{{ login.set_cookie }}"
register: vchosts
- name: Gather all registered virtual machines
vmware_vm_info:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
vm_type: vm
folder: "TheDataCenter/VM Folders Folder"
# Click the data center in vsphere, click VM folders, search for folder here.
# delegate_to: localhost