Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network is not started if inactive #1095

Open
dansrogers opened this issue Aug 31, 2024 · 1 comment
Open

Network is not started if inactive #1095

dansrogers opened this issue Aug 31, 2024 · 1 comment

Comments

@dansrogers
Copy link

System Information

Linux distribution

Ubuntu 24.04 LTS

Terraform version

$ terraform -v
Terraform v1.9.5-dev
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.6

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

Provider and libvirt versions

registry.terraform.io/dmacvicar/libvirt v0.7.6

libvirt-daemon                                 10.0.0-2ubuntu8.3                        amd64        Virtualization daemon

  • [X ] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:

Description of Issue/Question

Network is not started if it is down. If network is not set to autostart on boot, then after a restart it will be inactive. Terraform apply will not activate the network, and thus VMs that depend on that network will fail to start.

Setup

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

# Configure the Libvirt provider
provider "libvirt" {
  uri = "qemu:///system"
}

resource "libvirt_network" "cluster" {
  name = "cluster"
  mode = "route"
  addresses = ["10.0.1.0/24"]
  dhcp {
    enabled = true
  }
}

Steps to Reproduce Issue

$ terraform apply
$ virsh net-destroy cluster
$ terraform apply
# note that terraform doesn't bring up the network.  It must be manually started with virsh net-start cluster

If you include a domain definition, you'll get an error similar to the following if the cluster is not active:

╷
│ Error: error creating libvirt domain: Requested operation is not valid: network 'cluster' is not active
│ 
│   with module.worker.libvirt_domain.devlab_cluster,
│   on modules/libvirt_talos_host/main.tf line 27, in resource "libvirt_domain" "devlab_cluster":
│   27: resource "libvirt_domain" "devlab_cluster" {
│ 
╵

Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration?

no

@scabala
Copy link
Contributor

scabala commented Sep 2, 2024

I have encountered it as well. I believe this is just a limitation of current implementation and probably needs to be addressed.

ne-bknn added a commit to ne-bknn/terraform-provider-libvirt that referenced this issue Sep 11, 2024
Includes network activity status in terraform state,
thus allowing terraform to update network resource
in case it is inactive (e.g. after hypervisor reboot
or `virsh net-destroy`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants