Closed ratelbee closed 2 years ago
Arch Linux or Ubuntu 20.04 or Debian 11
Arch Linux
Ubuntu 20.04
Debian 11
Clents Ubuntu 20.04 Terraform 1.0.8
Terraform 1.0.8
Clents Arch linux Terraform 1.0.8
Arch linux
Virtual Host 1 Debian 11 libvirt 7.0.0 QEMU 5.2.0
libvirt 7.0.0
QEMU 5.2.0
Virtual Host 2 Arch linux libvirt 7.8.0 QEMU 6.1.0
libvirt 7.8.0
QEMU 6.1.0
Guest Machines ubuntu 20.04 cloud init Qemu-ga 4.2.1
ubuntu 20.04 cloud init
Qemu-ga 4.2.1
0.6.11
terraform { required_version = ">= 0.13" required_providers { libvirt = { source = "dmacvicar/libvirt" version = "0.6.11" } } } resource "libvirt_domain" "virt_machine" { count = var.vm_count name = format("${local.full_name}-%02d", count.index + var.index_start) memory = var.memory vcpu = var.vcpu autostart = var.autostart qemu_agent = true cloudinit = element(libvirt_cloudinit_disk.commoninit.*.id, count.index) cpu { mode = "host-passthrough" } network_interface { bridge = var.bridge wait_for_lease = false } xml { xslt = (var.hugepages == true ? file("${path.module}/xslt/hugepages.xsl") : null) } console { type = "pty" target_port = "0" target_type = "serial" } disk { volume_id = element(libvirt_volume.volume-qcow2.*.id, count.index) } graphics { type = "spice" listen_type = "address" autoport = true } } output "virtual_machines" { value = libvirt_domain.virt_machine.*.network_interface.0.addresses.0 }
After Guest Agent connect on libvirt host I use: virsh qemu-agent-command dhcp-test-00 '{"execute": "guest-network-get-interfaces"}' --pretty Return:
virsh qemu-agent-command dhcp-test-00 '{"execute": "guest-network-get-interfaces"}' --pretty
..... { "name": "ens3", "ip-addresses": [ { "ip-address-type": "ipv4", "ip-address": "172.16.1.63", "prefix": 24 }, { "ip-address-type": "ipv6", "ip-address": "fe80::5054:ff:fe7e:ec72", "prefix": 64 } ], "statistics": { "tx-packets": 25192, "tx-errs": 0, "rx-bytes": 107986739, "rx-dropped": 9, "rx-packets": 71710, "rx-errs": 0, "tx-bytes": 2081879, "tx-dropped": 0 }, ......
if run TF_LOG=DEBUG terraform refresh return:
TF_LOG=DEBUG terraform refresh
..... 2021/10/08 19:48:24 [DEBUG] Not implemented 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] no interfaces could be obtained with qemu-agent: falling back to the libvirt API 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] Not implemented 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] no interfaces could be obtained with qemu-agent: falling back to the libvirt API 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] Interfaces info obtained with libvirt API: 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: ([]libvirt.DomainInterface) <nil> 2021-10-08T19:48:24.028+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] read: addresses for '52:54:00:CE:52:FB': [] 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: 2021/10/08 19:48:24 [DEBUG] read: ifaces for 'dhcp-test-00': 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: ([]map[string]interface {}) (len=1 cap=1) { 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (map[string]interface {}) (len=10) { 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=6) "bridge": (string) (len=5) "br880", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=4) "vepa": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=7) "macvtap": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=11) "passthrough": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=8) "hostname": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=10) "network_id": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=12) "network_name": (string) "", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=9) "addresses": ([]string) <nil>, 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=3) "mac": (string) (len=17) "52:54:00:CE:52:FB", 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: (string) (len=14) "wait_for_lease": (bool) false 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: } 2021-10-08T19:48:24.029+0300 [DEBUG] provider.terraform-provider-libvirt_v0.6.11: } ....................... Error: Invalid index │ │ on .terraform/modules/node/output.tf line 2, in output "virtual_machines": │ 2: value = libvirt_domain.virt_machine.*.network_interface.0.addresses.0 │ │ The given key does not identify an element in this collection value: the collection has no elements.
duplicate of #891 ?
yeah!
Duplicate
Linux distribution
Arch Linux
orUbuntu 20.04
orDebian 11
Terraform version
Clents
Ubuntu 20.04
Terraform 1.0.8
Clents
Arch linux
Terraform 1.0.8
Virtual Host 1
Debian 11
libvirt 7.0.0
QEMU 5.2.0
Virtual Host 2
Arch linux
libvirt 7.8.0
QEMU 6.1.0
Guest Machines
ubuntu 20.04 cloud init
Qemu-ga 4.2.1
Provider versions
0.6.11
Description of Issue/Question
Setup
Steps to Reproduce Issue
After Guest Agent connect on libvirt host I use:
virsh qemu-agent-command dhcp-test-00 '{"execute": "guest-network-get-interfaces"}' --pretty
Return:if run
TF_LOG=DEBUG terraform refresh
return:Useful Feature does not work.