Based on the work of umair
Incus VM Template for Coder
Provision Linux VMs & Containers on Incus/LXD as Coder workspaces. The template deploys an instance with cloud-init, and runs the Coder agent under the workspace owner's Linux user.
Prerequisites
- Incus server / cluster with exposed API
Setup the template
- Create an Incus trust token:
incus config trust add coder # Save the token
- Setup an Incus project with a network:
incus project create Coder -c features.network=true
incus network create Main --project Coder
- Prepare
terraform.tfvarsin your environment:
remote_name = "iaas"
remote_address = "https://iaas.phorge.fr:443"
remote_token = "<token>"
remote_coder_project = "Coder"
remote_coder_network = "Main"
remote_coder_storage_pool = "local"
remote_coder_profiles = ["1vCPU-2GiB-disk20GiB", "2vCPU-4GiB-disk20GiB", "4vCPU-8GiB-disk60GiB"]
remote_coder_images = ["images:ubuntu/24.04/cloud", "images:debian/13/cloud", "images:alpine/3.23/cloud"]
Use
coder template push iaas-instance -d .
Warnings
Incus often works with cloud image, please use cloud tagged images such as images:ubuntu/22.04/cloud to be able to use cloud-init (Using non cloud tagged images will lead into your workspaces not working as the coder agent installs through cloud-init)