Terraform module for creating libvirt domains (VMs) with cloud-init and optional Ansible Automation Platform integration.
module "vm" {
source = "git::https://github.com/makeitworkcloud/terraform-libvirt-domain.git?ref=v1.0.0"
name = "my-vm"
description = "My virtual machine"
vcpu = 2
memory = 4096
cloudinit_meta_data_template = file("${path.module}/templates/meta-data.tpl")
cloudinit_meta_data_vars = { hostname = "my-vm" }
cloudinit_user_data_template = file("${path.module}/templates/user-data.tpl")
cloudinit_user_data_vars = {}
cloudinit_network_config_template = file("${path.module}/templates/network-config.tpl")
cloudinit_network_config_vars = { ip_address = "192.168.1.100" }
private_ip_addr = "192.168.1.100"
proxyhost = "bastion.example.com"
}| Name | Version |
|---|---|
| terraform | >= 1.3 |
| libvirt | ~> 0.9.0 |
| Name | Version |
|---|---|
| libvirt | ~> 0.9.0 |
No modules.
| Name | Type |
|---|---|
| libvirt_cloudinit_disk.commoninit | resource |
| libvirt_domain.vm | resource |
| libvirt_volume.boot | resource |
| libvirt_volume.cloudinit | resource |
| libvirt_volume.extra | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| boot_disk_size | Boot disk virtual size in bytes. Null means use the source image's natural size. | number |
null |
no |
| boot_image_url | URL for the base QCOW2 image used as the boot disk. | string |
"https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2" |
no |
| bridge_name | Name of the network bridge for the second network interface. | string |
"nm-bridge" |
no |
| cloudinit_meta_data_template | The template content for cloud-init meta-data configuration. | string |
n/a | yes |
| cloudinit_meta_data_vars | Variable map for the cloud-init meta-data template. | map(string) |
n/a | yes |
| cloudinit_network_config_template | The template content for cloud-init network configuration. | string |
n/a | yes |
| cloudinit_network_config_vars | Variable map for the cloud-init network configuration template. | map(string) |
n/a | yes |
| cloudinit_user_data_template | The template content for cloud-init user-data configuration. | string |
n/a | yes |
| cloudinit_user_data_vars | Variable map for the cloud-init user-data template. Set to {} if not used. | map(string) |
n/a | yes |
| description | Description for the libvirt domain (virtual machine). | string |
"" |
no |
| extra_volumes | List of additional volumes to attach to the domain. Each object should contain: - name: Name of the volume. - size: Size of the volume in bytes. Example: [ { name = "runner-var-lib-docker.qcow2" size = 107374182400 } ] |
list(object({ |
[] |
no |
| memory | Amount of memory (in MB) to assign to the domain. | number |
2048 |
no |
| name | The name of the libvirt domain (virtual machine) and related resources. | string |
n/a | yes |
| storage_pool | Name of the libvirt storage pool where volumes will be created. | string |
"default" |
no |
| vcpu | Number of virtual CPUs to assign to the domain. | number |
1 |
no |
| Name | Description |
|---|---|
| boot_volume_id | The ID of the boot volume |
| cloudinit_disk_id | The ID of the cloud-init disk |
| domain_id | The ID of the libvirt domain |
| domain_name | The name of the libvirt domain |