centos - 使用 libvirt_volume.source 的 URL 时如何指定 HTTP 身份验证(用户、密码)

标签 centos terraform virtual-machine kvm libvirt

我正在尝试使用 Terraform 配置 VM。
我给出了 vm 的源图像
这里:
来源=“http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2”
但是这个站点需要用户名和密码。
我在哪里以及如何在我的 tf 文件中指定该站点的凭据?
这是我的 main.tf 文件:

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

provider "libvirt" {
    uri = "qemu:///system"
}

resource "libvirt_volume" "centos7-qcow2" {
  name = "centos7.qcow2"
  pool = "default"
  source = "http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2"
  format = "qcow2"
}

# Define KVM domain to create
resource "libvirt_domain" "gw" {
  name   = "gw"
  memory = "8192"
  vcpu   = 4

  network_interface {
    network_name = "default"
  }

  disk {
    volume_id = "${libvirt_volume.centos7-qcow2.id}"
  }

  console {
    type = "pty"
    target_type = "serial"
    target_port = "0"
  }

  graphics {
    type = "spice"
    listen_type = "address"
    autoport = true
  }
}
当我运行 terraform apply 我得到这个错误:
*Error while determining image type for http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2: Can't retrieve partial header of resource to determine file type: http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2 - 401 Authorization Required

   with libvirt_volume.centos7-qcow2,
   on main.tf line 13, in resource "libvirt_volume" "centos7-qcow2":
   13: resource "libvirt_volume" "centos7-qcow2" {*
感谢您的帮助!

最佳答案

我刚刚将密码和用户添加到 URL,如下所示:
http://user:password@host/path
:)

关于centos - 使用 libvirt_volume.source 的 URL 时如何指定 HTTP 身份验证(用户、密码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69808161/

相关文章:

linux - 需要一个 Linux 内存利用工具

linux - Bash 数组不接受通配符

linux - 80 端口上的 pdflush 阻止 Apache 重新启动

apache - 如何在 CentOS 7 上使用 python3.5 为 apache 2.4+ 安装 mod_wgsi

google-cloud-platform - (Terraform) 左操作数 : a number is required 的值不合适

terraform - 如何在 terraform entreprise 中使用 npm?

azure - AKS 和 ACR 之间的专用终结点

python - 在centos 6.x 上使用python3 安装twis​​ted 失败?

linux - Vagrant 在访客计算机中创建多个终端

java - 如何清理tomcat缓存?