This set of modules has been created to streamline the creation of libvirt resources using the awesome terraform-provider-libvirt by dmacvicar!
Caution
The module is retrocompatible with version 0.8.x of the provider, it is enough to specify the version in the modules source!
With this module you will be able to create from scratch with a few parameters:
These are minimal examples, the full examples are available in the examples directory.
terraform-libvirt-network:
module "libvirt_network" {
source = "kubealex/libvirt-resources/libvirt//modules/terraform-libvirt-network"
# version = "0.1.3" # Uncomment only if you are using the version 0.8.x of the provider
network_autostart = true
network_name = "example_network"
network_mode = "nat"
network_domain = "example.com"
network_cidr = ["192.168.122.0/24"]
network_bridge = "br0"
network_mtu = 1500
network_dns_local = false
network_dhcp_enabled = true
network_dhcp_range_start = "192.168.122.15"
network_dhcp_range_end = "192.168.122.50"
network_dnsmasq_options = {
"server" = "/example.com/192.168.122.1"
}
network_dns_entries = {
"example" = "192.168.122.2"
}
network_routes = {
"10.0.0.0/24" = "10.0.0.1"
}
network_dns_srv_records = [
{
service = "_http"
protocol = "_tcp"
domain = "example.com"
target = "server1.example.com"
port = 80
priority = 10
weight = 5
},
{
service = "_ldap"
protocol = "_tcp"
domain = "example.com"
target = "server2.example.com"
port = 389
priority = 20
weight = 10
}
]
}terraform-libvirt-pool:
module "libvirt_pool" {
source = "kubealex/libvirt-resources/libvirt//modules/terraform-libvirt-pool"
# version = "0.1.3" # Uncomment only if you are using the version 0.8.x of the provider
pool_name = "my_pool"
pool_path = "/path/to/pool"
}terraform-libvirt-instance:
module "instance_provisioning" {
source = "kubealex/libvirt-resources/libvirt//modules/terraform-libvirt-instance"
# version = "0.1.3" # Uncomment only if you are using the version 0.8.x of the provider
instance_count = 2
instance_cloud_image = "https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2"
instance_type = "linux"
instance_hostname = "web-server"
instance_domain = "example.com"
instance_cpu = 2
instance_memory = 4
instance_volume_size = 50
instance_cloud_user = {
username = "admin"
password = "securepass"
sshkey = "ssh-rsa AAAAB3NzaC1yc2EAAA...your-ssh-key-here"
}
instance_libvirt_network = "default"
instance_libvirt_pool = "default"
instance_uefi_enabled = true
instance_firmware = "/usr/share/edk2/ovmf/OVMF_CODE.fd"
instance_network_interfaces = [
{
interface_network_name = "default"
interface_mac_address = "52:54:00:12:34:56"
interface_address = "192.168.1.2"
interface_prefix = 24
interface_hostname = "eth0-host"
interface_wait_for_lease = true
},
{
interface_network_name = "default"
interface_mac_address = "52:54:00:65:78:9A"
interface_address = "192.168.2.2"
interface_prefix = 16
interface_hostname = "eth1-host"
interface_wait_for_lease = false
},
]
}