Dec 13, 2023 3 min read

How To Deploy A Proxmox Virtual Machine With Ansible

Build and deploy proxmox virtual machine with ansible automation workflow and scripts.

How To Deploy A Proxmox Virtual Machine With Ansible
Table of Contents

In one of my previous blog articles I wrote about how to deploy a proxmox virtual machine with Terraform but the truth is there are a couple of methods to achieve the same outcome of deploying a Linux virtual machine to your Promox host. As some of you already know I am an automation junkie and Ansible is also one of my favorite software tools to build automation. In today's article, we're building out an Ansible playbook that deploys a Linux virtual machine to our Proxmox virtual host.

Prerequisite Initial Steps

Our initial first steps will be to ensure that we have a Linux VM template image that we want to deploy. In my case I have an Ubuntu Linux Template that I built with Packer like in the example below if you want to do the same. Otherwise you can go ahead to and download one of the images on Ubuntu's official site.

How To Build Images With Packer For Proxmox
Step by step on how to build custom images with Packer for Proxmox tutorial.
Ubuntu 20.04.6 LTS (Focal Fossa)
CD images for Ubuntu 20.04.6 LTS (Focal Fossa)

Ansible Playbook To Create Virtual Machine On Proxmox

Adjust the following script according to your Proxmox environment and execute it to create your VM on your Proxmox Host with Ansible:

  - name: Create VM Proxmox
    hosts: proxmox
      - "./vars/proxmox_vars.yml"
    - name: Create proxmox virtual machine
        api_user      : root@pam
        api_password  : prox_password #proxmox password
        api_host      : #proxmox host ip addr
        clone         : 100
        clone_type    : full
        cpus          : 1
        cores         : 4
        memory        : 4096
        onboot        : true
        netif         : '{"net0":"name=eth0,gw=,ip=,bridge=vmbr0"}'
        hostname      : 'exampleVM'
        storage       : local-lvm
        node          : 'vh1' #proxmox hostname

Once the playbook completes successfully you can start utilizing your newly created virtual machine. If you are looking to set extra configs visit the Ansible Proxmox website here:

community.general.proxmox module – Management of instances in Proxmox VE cluster — Ansible Documentation


In conclusion, Ansible is one of the best opensource automation and configuration management tools and can integrate with many other platforms and tools and by following this tutorial you can automate the creation of Proxmox Virtual Machines with one Ansible Playbook . If you enjoyed this article consider signing up for our newsletter and don't forget to share it with people that would find it useful. Leave a comment below with a tutorial you would like us to cover.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Opensource Geeks.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.