Skip to content

frosty-geek/tf-libvirt-example

Repository files navigation

tf-libvirt-example

A simple way to spawn ubuntu VMs

TL;DR just do it

$ terraform init

# see minimal variables below

$ terraform plan
$ terraform apply

variables

minimal variables needed to run

$ cat < EOF > terraform.tfvars
hostname = "server1"
domainname = "example.com"
EOF

terraform workspaces

terraform workspace new server1.example.com
terraform workspace select server1.example.com
terraform apply -var="hostname=server1" -var="domainname=example.com"

Update terraform-docs

terraform-docs markdown table --output-file README.md --output-mode inject .

Requirements

Name Version
terraform >= 1.1.7
libvirt >= 0.6.14

Providers

Name Version
libvirt 0.6.14
template 2.2.0

Modules

No modules.

Resources

Name Type
libvirt_cloudinit_disk.cloudinit resource
libvirt_domain.vm resource
libvirt_volume.vm-volume-base resource
libvirt_volume.vm-volume-data resource
libvirt_volume.vm-volume-root resource
template_file.userdata data source

Inputs

Name Description Type Default Required
autostart autostart vm (default false) bool false no
domainname domainname used to generate fqdn for cloud-init string n/a yes
hostname hostname used in filenames + cloud-init string n/a yes
image_release image release name used in filenames + image_url regex replace (default focal) string "focal" no
image_url cloud-images URL %RELEASE% will be regex replaced with $image_release (default ubuntu cloud-images) string "https://cloud-images.ubuntu.com/%RELEASE%/current/%RELEASE%-server-cloudimg-amd64.img" no
libvirt_uri libvirt connection uri string "qemu:///system" no
networks list of network bridges to attach to (default virbr0) list(string)
[
"virbr0"
]
no
ssh_public_key ssh public keyfile for cloud-init (default ~/.ssh/id_rsa.pub) string "~/.ssh/id_rsa.pub" no
username username for cloud-init string "ubuntu" no
vcpu vCPUs of the VM (default 1) number 1 no
volume_data_enabled volume for data disk enabled? (default false) bool false no
volume_format volume file format, used for cloud-images + local files (default qcow2) string "qcow2" no
volume_pool volume pool to save local files to (default default) string "default" no
volume_size_data volume size for data disk (default 50GB) number 53687091200 no
volume_size_root volume size for root disk (default 10GB) number 10737418240 no
vram RAM of the VM (default 2GB) number 2048 no

Outputs

No outputs.

About

Terraform libvirt example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages