Terraform KVM provider incorrectly using IPv6 address

I am trying to get Terraform to create a VM on a KVM machine. It creates the VM but terraform is trying to connect to the VM with an IPv6 address of fe80::3e26:223c:7a13:fc9b. The machine I am running this on had IPv6 disabled in multiple locations and it is showing no IPv6 addresses if I run ip a. The config in my main.tf file contains no IPv6 addresses and I specify only IPv4 addresses. Right off the bat if I run terraform apply it says it’s going to create a VM with the above IPv6 address. I have specified to use an IPv4 address. When it fails, after a few mins, it fails with “timeout - last error: dial tcp [fe80::3e26:223c:7a13:fc9b]:22: socket: address family not supported by protocol”

The only thing I can find on the net is this page, but there is no resolution and no fix from Hashicorp in the 3 years since it was raised.

terraform {
required_version = “>= 0.13”
required_providers {
libvirt = {
source = “dmacvicar/libvirt”

provider “libvirt” {
uri = “qemu:///system”

module “vm” {
source = “MonolithProjects/vm/libvirt”
version = “1.8.0”

vm_hostname_prefix = “server”
vm_count = 1
memory = “2048”
vcpu = 1
pool = “default”
system_volume = 100
dhcp = false
ip_address = [ “” ]
ip_gateway = “”
bridge = “br0”
local_admin = “vagrant”
ssh_admin = “ci-user”
ssh_private_key = “/home/centos/.ssh/id_rsa”
local_admin_passwd = var.admin_password
ssh_keys = [
“ssh-rsa xxxxxxx”
time_zone = “CET”

os_img_url = “file:///vmdata/templates/tdhtest”

output “outputs” {
value = module.vm

$ terraform apply
module.vm.data.template_file.init_config[0]: Reading…
module.vm.data.template_file.network_config[0]: Reading…
module.vm.data.template_file.init_config[0]: Read complete after 0s [id=15be391f115d29c18b33e06e0faf17454cdcf961c59984bc9a590ec431a99265]
module.vm.data.template_file.network_config[0]: Read complete after 0s [id=21c35b5b423842cb572e738e09a0c19419a19226fd62699cb07acf16448fabfb]
module.vm.data.template_cloudinit_config.init_config[0]: Reading…
module.vm.data.template_cloudinit_config.init_config[0]: Read complete after 0s [id=3178718758]
module.vm.libvirt_cloudinit_disk.commoninit[0]: Refreshing state… [id=/vmdata/pools/default/server_init 1.iso;dbc8ac22-6cc0-47a4-a2f0-2ef59548e54b]
module.vm.libvirt_volume.base-volume-qcow2[0]: Refreshing state… [id=/vmdata/pools/default/server-base.qcow2]
module.vm.libvirt_volume.volume-qcow2[0]: Refreshing state… [id=/vmdata/pools/default/server01.qcow2]
module.vm.libvirt_domain.virt-machine[0]: Refreshing state… [id=06d37f4f-0e15-4bb2-b83f-9c8b0241230d]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

module.vm.libvirt_domain.virt-machine[0] is tainted, so must be replaced

-/+ resource “libvirt_domain” “virt-machine” {
~ arch = “x86_64” → (known after apply)
- cmdline = → null
~ emulator = “/usr/libexec/qemu-kvm” → (known after apply)
~ id = “06d37f4f-0e15-4bb2-b83f-9c8b0241230d” → (known after apply)
~ machine = “pc” → (known after apply)
name = “server01”
# (7 unchanged attributes hidden)

  ~ graphics {
      - websocket      = 0 -> null
        # (4 unchanged attributes hidden)

  ~ network_interface {
      ~ addresses      = [
          - "fe80::3e26:223c:7a13:fc9b",
        ] -> (known after apply)
      ~ mac            = "52:54:00:A2:3A:41" -> (known after apply)
      + network_id     = (known after apply)
      + network_name   = (known after apply)
        # (3 unchanged attributes hidden)

    # (4 unchanged blocks hidden)

Plan: 1 to add, 0 to change, 1 to destroy.

Changes to Outputs:

  • outputs = {
    • ip_address = [
      • (known after apply),
    • name = [
      • “server01”,

Do you want to perform these actions?
Terraform will perform the actions described above.
Only ‘yes’ will be accepted to approve.

Enter a value: yes

module.vm.libvirt_domain.virt-machine[0]: Destroying… [id=06d37f4f-0e15-4bb2-b83f-9c8b0241230d]
module.vm.libvirt_domain.virt-machine[0]: Destruction complete after 0s
module.vm.libvirt_domain.virt-machine[0]: Creating…
module.vm.libvirt_domain.virt-machine[0]: Still creating… [10s elapsed]
module.vm.libvirt_domain.virt-machine[0]: Provisioning with ‘remote-exec’…
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Connecting to remote host via SSH…
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Host: [fe80::3e26:223c:7a13:fc9b]
module.vm.libvirt_domain.virt-machine[0] (remote-exec): User: ci-user
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Password: false
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Private key: true
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Certificate: false
module.vm.libvirt_domain.virt-machine[0] (remote-exec): SSH Agent: false
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Checking Host Key: false
module.vm.libvirt_domain.virt-machine[0] (remote-exec): Target Platform: unix
module.vm.libvirt_domain.virt-machine[0]: Still creating… [2m10s elapsed]
│ Error: remote-exec provisioner error
│ with module.vm.libvirt_domain.virt-machine[0],
│ on .terraform/modules/vm/main.tf line 71, in resource “libvirt_domain” “virt-machine”:
│ 71: provisioner “remote-exec” {
│ timeout - last error: dial tcp [fe80::3e26:223c:7a13:fc9b]:22: socket: address family not supported by protocol

You have not included the contents of your Terraform configuration file for the thing that is failing. The file name is included in the error message.

I included my main.tf file contents at the top. Is there something else I should include?

I did find a partial solution which was to use the libvirt provider directly.