Playbooks for Proxmox automation - Work in progress
- Integrate into Semaphore
- Integrate Semaphore into Netbox Webhook
- Integrate package installation for the provisioned VM
- Integrate usage of vault instead of
.env
file - Integrate auto decommissioning on delete (dangerzone!)
Netbox must be fully setup and configured for this to work. We use different features of netbox, here is what you need to have:
You need to create at least one proxmox host as device. The following fields must be present:
- Description (This must be the node name in proxmox)
- Primary IP assigned
You also need to create a platform for each VM OS you're going to use, aswell as each LXC template. LXC platforms need to start with lxc-
The primary IP-address assigned to the proxmox device in netbox, needs the following fields set:
- dns_name: This is the FQDN which is used for the proxmox API communication.
- Cluster type: Just create "Proxmox"
- Clusters: Create your pve cluster
Assign the proxmox hosts you created as device before to the newley created cluster.
You need to create the following tags:
tag name | applies to | description |
---|---|---|
<pve_datastore_name> | Virtual Disks | This tag is applied to virtual disks to determine on which datastore they get provisioned. |
no-auto-provisioning | Virtual machines | In the future this tag is used to skip the creation of certein VMs |
pve-provisioned | Virtual machines | This tag will be applied once the VM is created, to prevent duplications |
Create a config template for each LXC template you're using. The property name is proxmox_template
and the value is the unique identifier of the template, eg:
{
"proxmox_template": "local:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst"
}
You need to map this config template to the corresponding plattform you've created before.
Create an API token with write access and save it.
you need to create a VM template, with cloud-init enabled, in proxmox. Make sure, that the template name equals to the platform slug in netbox.
Download all LXC templates you want to use. Map them to config templates in netbox as mentioned above
Create a API token for root@pam and safe it. The FQDN of proxmox needs a trusted TLS certificate.
Currently only manual run is possible, in the future it will trigger a semaphore webhook, but I first need to set this up and document it.
So meanwhile, you can do the following:
- Create a virtual machine in netbox. Required fields:
- name
- cluster
- device (for now)
- platform
- primary IPv4
- config template (only if LXC)
- vCPUs
- Memory
- Disk
- Add a virtual disk. required fields:
- virtual machine
- Size
- Tag (use the datastore tag)
- Copy the
.env.dist
file to.env
and fill in your netbox and proxmox API token, aswell as your netbox FQDN. - Set the
NETBOX_VMLXC_ID
env variable to the VM ID in netbox. You can find it in the URL. - Run
ansible-playbook test-vm-staging-with-lxc.yml
If you want your DNS records in netbox auto synced to your provider, have a look at my Netbox-OctoDNS-syncer