Use this when deciding how VMs should be built and changed by code — which API, tool and template — or when an automated VM job fails or produces inconsistent machines.
Automation
Virtualization automation means creating, changing and retiring VMs through APIs, scripts and declarative tools — Terraform, Ansible, PowerShell, cloud-init — instead of clicking through a console, so builds are repeatable and auditable.
1. Automate provisioning, configuration and lifecycle.
2. Use APIs/IaC with version control.
3. Idempotent tools.
4. Secure API tokens.
5. Test in lab.
code → API → hypervisor → VMs
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
VM provisioning is creating a ready-to-use VM: choose host or cluster, clone or build from an image, size CPU, memory and disks, attach networks, apply guest customization, and hand it over with monitoring and backup enabled.
Subtopic Infrastructure as CodeInfrastructure as Code declares VMs, networks and storage in versioned files (Terraform, Pulumi, Bicep, Ansible), so changes are reviewed, planned and applied consistently, and drift from the declared state can be detected.
Subtopic TemplatesAutomation templates are reusable definitions — a VM template, a Terraform module, a cloud-init or Ansible role — with parameters for name, size and network, so many VMs can be produced from one tested pattern.
Subtopic APIsHypervisor APIs (vSphere API, Hyper-V WMI/PowerShell, libvirt, Proxmox REST, cloud provider APIs) expose VM, network and storage operations to scripts and tools; authenticate with a scoped service account and use the API's task status to confirm results.
Subtopic CLI AutomationCLI automation drives hypervisors from shell scripts with tools like virsh and virt-install (KVM), qm (Proxmox), govc or esxcli (vSphere) and Hyper-V PowerShell, which suits quick bulk changes and troubleshooting.
Subtopic PowerShellPowerShell automates Hyper-V with the Hyper-V module (New-VM, Set-VMProcessor, Checkpoint-VM) and vSphere with VMware PowerCLI (Connect-VIServer, New-VM, Get-Stat), covering bulk provisioning, reporting and changes.
Subtopic AnsibleAnsible automates virtualization with agentless playbooks and modules such as community.vmware, community.libvirt and community.general.proxmox to create VMs, change hardware and configure the guest OS in one idempotent run.
Subtopic TerraformTerraform provisions VMs declaratively with providers for vSphere, Proxmox, Hyper-V, libvirt and clouds; terraform plan shows what will change, apply makes it so, and the state file tracks what Terraform manages.
Subtopic Cloud-initCloud-init is the first-boot agent in most Linux cloud images: it reads user-data and meta-data from a datasource (NoCloud ISO, config drive, metadata service) to set hostname, users, SSH keys, network, packages and run commands.
Subtopic Automated DeploymentAutomated deployment chains provisioning steps — clone template, set CPU/RAM/disk/network, inject identity with cloud-init or Sysprep, configure the guest, register in monitoring — into a pipeline that runs the same way every time.
- Job finished ≠ VM is configured and reachable.
- Template updated ≠ existing VMs changed.
- API call accepted ≠ hypervisor task succeeded; poll the task.
pvesh get /version— API reachable (Proxmox)Get-Command -Module Hyper-V | measure— Hyper-V cmdletsterraform plan— IaC plan
ReferenceWhy it matters1 section · depth on demand
Automation tools by platform
| Platform | Tools |
|---|---|
| vSphere | PowerCLI, Terraform vsphere provider, Ansible community.vmware |
| Hyper-V | PowerShell, Windows Admin Center, SCVMM |
| Proxmox | REST API, pvesh, Terraform (bpg/proxmox), Ansible community.general.proxmox* |
| KVM | libvirt API, virt-install, Ansible, OpenTofu |
Combine with templates/cloud-init for guest configuration, and keep definitions in Git.
ReferenceHow it works1 section · depth on demand
In depth
Automation in virtualization covers provisioning, configuration, lifecycle and reporting. Typical toolchain:
| Task | Tools |
|---|---|
| Create VMs and infrastructure | Terraform/OpenTofu providers, Ansible modules, PowerCLI, Proxmox API |
| Configure guests | cloud-init, Ansible, DSC, sysprep unattend |
| Templates | Packer image builds |
| Day-2 operations | Ansible, PowerShell, scheduled scripts, vRO/Aria |
| Reporting | PowerCLI, API exports to CMDB/monitoring |
Keep definitions in Git, run them from CI with service accounts, and treat manual console changes as drift to be reconciled.
ReferenceImportant terms & boundaries1 section · depth on demand
Examples
# PowerCLI
Get-VM | Where-Object PowerState -eq PoweredOn | Select Name,NumCpu,MemoryGB
# Proxmox API via CLI
pvesh get /cluster/resources --type vm --output-format json
# Hyper-V
Get-VM | Where-Object State -eq Running | Select Name,ProcessorCount,MemoryAssigned
Documented example, not captured output. Terraform providers (vsphere, proxmox) and Ansible collections (community.vmware, community.general.proxmox) automate provisioning.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/html/index.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.