We will now try to carry out some higher-level infrastructure management. We will try to create a VMware cluster and add an ESXi host to it:
---
- name: Create a VMware cluster and populate it
hosts: localhost
gather_facts: False
tasks:
- name: Create a VMware virtual cluster
vmware_cluster:
hostname: 'vcenter.edu.lab'
username: '[email protected]'
password: 'VMp@55w0rd'
datecenter: 'vcenter.edu.lab'
validate_certs: no
cluster_name: "LabCluster"
state: present
enable_ha: yes
enable_drs: yes
enable_vsan: no
- name: Add a VMware ESXi host to the newly created
Cluster
vmware_host:
hostname: 'vcenter.edu.lab'
username: '[email protected]'
password: 'VMp@55w0rd'
datecenter: 'vcenter.edu.lab'
validate_certs: no
cluster_name: " LabCluster "
esxi_hostname: "esxi1.lab.edu"
esxi_username: "root"
esxi_password: "E5X1P@55w0rd"
state: present
These playbooks can replace both the PowerCLI commands that are used to manage the VCenter and the manual process of accessing the Windows client or the web interface to manage hosts and clusters.