Pcornel
Browse topics
Options
Recent
Favorites
Virtualization · Technical reference

Ansible

Direct answer

Ansible 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.

When to use this

Use this when automating VM creation or guest configuration with Ansible playbooks against VMware, libvirt or Proxmox.

First 30 seconds

1. Ansible manages VMs via modules (proxmox_kvm, vmware_guest, virt).

2. Use dynamic inventory.

3. Idempotent playbooks.

4. Vault for secrets.

5. Run in check mode first.

Operational verification

playbook → module → API → VM

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
virtualization
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformvirtualization
Scope / prerequisiteUse this when automating VM creation or guest configuration with Ansible playbooks against VMware, libvirt or Proxmox.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Checks Verify boundary
ansible-galaxy collection list | grep -E 'vmware|proxmox'
ansible-playbook vm.yml --check --diff
Step 2 Common mistakes Narrow the fault
  • Collections not pinned (requirements.yml).
  • Credentials in playbooks instead of Ansible Vault or a secret store.
  • Not waiting for guest tools/IP before the next task (wait_for).
Evidence references

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.

observation · 1
Key points
  • Module ok ≠ guest configured; that is a second play.
  • Collections and SDKs must match the platform version.
  • Check mode shows intent, not guest effects.
Key checks
  • ansible-galaxy collection list | grep -E 'community.general|community.vmware|community.libvirt' — collections installed
  • ansible-playbook vm.yml --check — dry run
  • ansible-inventory --graph — dynamic inventory
ReferenceWhy it matters1 section · depth on demand

In depth

Ansible manages virtualization through collections: community.vmware/vmware.vmware, community.general.proxmox_kvm, microsoft.hyperv-style modules or ansible.windows with PowerShell, and community.libvirt.

- name: Clone VM from template
  community.general.proxmox_kvm:
    api_host: pve1
    api_user: automation@pve
    api_token_id: ci
    api_token_secret: "{{ vault_pve_token }}"
    clone: ubuntu-2404-tpl
    newid: 130
    name: web01
    node: pve1
    full: true
    storage: local-zfs

Keep API credentials in Ansible Vault or an external secret store, never in playbooks.

ReferenceImportant terms & boundaries2 sections · depth on demand

Example

- name: Create VM from template
  community.vmware.vmware_guest:
    hostname: vcenter.corp.local
    name: web01
    template: tpl-debian12
    datacenter: DC1
    cluster: CL1
    state: poweredon

Documented example, not captured output. Proxmox: community.general.proxmox_kvm.

Proxmox example

- community.general.proxmox_kvm:
    api_host: pve1
    api_user: automation@pve
    api_token_id: ansible
    api_token_secret: "{{ vault_pve_token }}"
    clone: tpl-debian12
    newid: 160
    name: app06
    node: pve1

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docvirtualization current

Authoritative/upstream documentation reviewed for bounded claims in Automation → Ansible. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://libvirt.org/html/index.html · confidence 94%
Confirmation

Confirm action

Continue?