dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.58k stars 456 forks source link

Cannot connect to ipv6 address with explicitly specified port #1049

Open MaxMatti opened 10 months ago

MaxMatti commented 10 months ago

System Information

Linux distribution

NixOS

Terraform version

terraform -v
Terraform v1.6.4-dev
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.4

Your version of Terraform is out of date! The latest version
is 1.6.4. You can update by downloading from https://www.terraform.io/downloads.html

Checklist

Description of Issue/Question

Setup

terraform {
  required_providers {
    libvirt = {
      source = "dmacvicar/libvirt"
    }
  }
}

provider "libvirt" {
  uri = "qemu+ssh://username@[::1]:22/system?name=qemu%3A%2F%2F%2Fsystem"
}

Steps to Reproduce Issue

$ terraform plan

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: failed to connect: dial tcp: address ::1:22: too many colons in address
│ 
│   with provider["registry.terraform.io/dmacvicar/libvirt"],
│   on host1.tf line 9, in provider "libvirt":
│    9: provider "libvirt" {
│ 
╵

Am I specifying the ip address incorrectly? I also tried without the [] but got the same error message.

MaxMatti commented 9 months ago

It can be fixed by replacing one function call in line 148 of ssh.go like this: patch.txt Unfortunately I have no idea how to create a test for that (finding this bug was my first time reading any go source code), so I don't feel confident to create a pull request.

scabala commented 3 weeks ago

Somewhat related to #1058 (generic SSH improvements)