Ansible Notes

Mindwatering Incorporated

Author: Tripp W Black

Created: 06/24 at 10:28 AM

 

Category:
Linux
Other

Ansible VMware REST API
Prereqisites:
- Ansible => 2.9.10
- Python => 3.6
- AIOHTTP (virtualenv)


Setup:
$ pip install aiohttp
(CentOS/Fedora - $ sudo dnf install python3-aiohttp)

$ ansible-galaxy collection install vmware.vmware_rest


Notes:
MORefID key is used to identify Datacenter(s), folder(s), and VMs
We don't have to follow the tree. For example, we can get the cluster, without using the datacenter MORefID.
Docs are at:
$ ansible-doc -t module vmware.vmware_rest.vcenter_cluster_info

To test from a local machine:
$ export VMWARE_HOST=myvsphere.mindwatering.net
$ export VMWARE_USER = myadmin@vsphere.local
$ export VMWARE_PASSWORD = mypwd
$ export VMWARE_VALIDATE_CERTS = no
$ ansible-playbook myplaybook.yml

$ vi listDatacenters.yml
- name: List of Datacenters
vmware.vmware_rest.vcenter_datacenter_info:
register: mw_datacenters

Output:
{
"value": [
{
"name": "mw_dc",
"datacenter": "datacenter-1234"
}
],
"changed": false
}








previous page