dmacvicar / terraform-provider-libvirt

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

help wanted - Error retrieving interface addresses: Message='invalid network pointer in virNetworkGetDHCPLeases') #736

Closed lawrend71 closed 4 years ago

lawrend71 commented 4 years ago

ISSUE: Hello, not sure if this is the right place for this, if not, I'll try to ask elsewhere. I have searched ( a lot ), but can't really find anywhere else, maybe stack overflow.

I am really wanting to use terraform with KVM at work. I can provision a VM with Virsh fine. I am now trying terraform to do this, and I keep getting an error, I have changed the arguments in various places to achieve this, but I can't seem to get it right. I want to create a VM on a bridged network with a static IP address.

ERROR: Error: Error retrieving interface addresses: Error retrieving interface addresses: virError(Code=36, Domain=19, Message='invalid network pointer in virNetworkGetDHCPLeases')

ERROR WITH DEBUG ON: 020-05-04T16:12:31.363+0100 [DEBUG] plugin.terraform-provider-libvirt: 2020/05/04 16:12:31 [DEBUG] qemu-agent is not used 2020-05-04T16:12:31.363+0100 [DEBUG] plugin.terraform-provider-libvirt: 2020/05/04 16:12:31 [DEBUG] no interfaces could be obtained with qemu-agent: falling back to the libvirt API 2020/05/04 16:12:31 [ERROR] : eval: terraform.EvalRefresh, err: Error retrieving interface addresses: Error retrieving interface addresses: virError(Code=36, Domain=19, Message='invalid network pointer in virNetworkGetDHCPLeases') 2020/05/04 16:12:31 [ERROR] : eval: terraform.EvalSequence, err: Error retrieving interface addresses: Error retrieving interface addresses: virError(Code=36, Domain=19, Message='invalid network pointer in virNetworkGetDHCPLeases') 2020/05/04 16:12:31 [TRACE] [walkRefresh] Exiting eval tree: libvirt_domain.terraform_test 2020/05/04 16:12:31 [TRACE] vertex "libvirt_domain.terraform_test": visit complete 2020/05/04 16:12:31 [TRACE] vertex "libvirt_domain.terraform_test": dynamic subgraph encountered errors 2020/05/04 16:12:31 [TRACE] vertex "libvirt_domain.terraform_test": visit complete

Error: Error retrieving interface addresses: virError(Code=36, Domain=19, Message='invalid network pointer in virNetworkGetDHCPLeases')

VERSIONS: Hypervisor: libvirtd (libvirt) 4.5.0 qemu-img version 2.12.0 cockpit-bridge Version: 196.3 CentOS Linux release 8.1.1911 (Core)

Guest running Terraform from: Terraform v0.12.24

CONFIG:


provider "libvirt" { uri = "qemu+ssh://root@192.168.0.100/system" }

resource "libvirt_volume" "testCentos7" { provider = libvirt name = "testCentos7.qcow2" pool = "default" source = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1907.qcow2" format = "qcow2" }

resource "libvirt_network" "test_network" { name = "test_network" mode = "bridge" addresses = ["192.168.0.31/24"] bridge = "virbr0" dhcp { enabled = false } autostart = true

resource "libvirt_domain" "terraform_test" { name = "terraform_test" memory = "4096" vcpu = 2 qemu_agent = true autostart = true

    network_interface {
      network_id = libvirt_network.test_network.id
      addresses = ["192.168.0.31"]
     bridge = "virbr0"       
     }

disk {
    volume_id = "libvirt_volume.testCentos7.id"
     }

}

QUESTION I am not sure if I should be specifying the static IP in the VM section, I'm sure I do have too.

Can anyone help, what am I doing wrong ...

thanks David.

lawrend71 commented 4 years ago

I managed to do this by using simple config instead, and am now looking at using cloud-init to configure vm. It seems to be the way of doing things from looking at the various posts here...

thanks David