You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?
Make sure you explain why this option is important to you, why it should be important to everyone. Describe your use-case with detail and provide examples where possible.
If it is a very special case, consider using the XSLT support in the provider to tweak the definition instead of opening an issue
Maintainers do not have expertise in every libvirt setting, so please, describe the feature and how it is used. Link to the appropriate documentation
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
When calling libvirt resources within a module, it does not support the provider configuration provided by the caller. Having a module to create virtual machines provides a easy way to create them in mass rather than creating multiple similar resources at the root configuration.
lets say I have a module machine in {working_dir}/machine:
Setup
main.tf:
terraform {
required_providers {
libvirt = {
source ="registry.terraform.io/dmacvicar/libvirt"
version ="0.7.6"
}
}
}
provider"libvirt" {
uri ="qemu:///session"
}
module"vm" {
source ="./machine"
count =3
name = vm[count.index]
...
}
./machine/main.tf:
terraform {
required_providers {
libvirt = {
source ="registry.terraform.io/dmacvicar/libvirt"
version ="0.7.6"
}
}
}
provider"libvirt" {
uri ="qemu:///session"
}
resource"libvirt_volume""root" {
name ="${var.name}.qcow2"
source =var.vm_image
size =10*1024*1024*1024# convert GB to bytes
pool =var.pool_name
}
resource"libvirt_domain""main" {
name =var.name
vcpu =var.cpuscpu {
mode ="host-passthrough"
}
network_interface {
network_id =var.network_id
hostname =var.hostname==null?var.name:var.hostname
addresses = [var.ip_address]
wait_for_lease =false
}
disk {
volume_id = libvirt_volume.root.id
scsi ="true"
}
}
Steps to Reproduce Issue
Create a module that uses libvirt provider.
Call the module created from terraform root configuration.
run terraform init
terraform init
Initializing the backend...
Initializing modules...
╷
│ Error: Module is incompatible with count, for_each, and depends_on
│
│ on machines.tf line 16, in module "vm":
│ 16: count = 3
│
│ The module at module.machine is a legacy module which contains its own local provider configurations, and so calls to it may not use the count, for_each, or depends_on arguments.
│
│ If you also control the module "./machine", consider updating this module to instead expect provider configurations to be passed by its caller.
removing provider block from ./machines/main.tf allows module to work but no longer runs with correct context of qemu:///session, and defaults to qemu:///system.
# removed this blockprovider"libvirt" {
uri ="qemu:///session"
}
Removing terraform block from ./machines/main.tf causes module not correctly resolve.
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/libvirt: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/libvirt
│
│ Did you intend to use dmacvicar/libvirt? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/libvirt, run the following
│ command:
│ terraform providers
Additional information:
Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? No
Have you tried to reproduce the issue without them enabled? n/a
The text was updated successfully, but these errors were encountered:
I too see an important need for this: when writing modules, I may make use of virsh on multiple bare metal nodes to accomplish one orchestration event. I should not know as the caller that there are more than one endpoints.
System Information
Linux distribution
Ubuntu 22.04
Terraform version
Provider and libvirt versions
Checklist
Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?
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
When calling
libvirt
resources within a module, it does not support the provider configuration provided by the caller. Having a module to create virtual machines provides a easy way to create them in mass rather than creating multiple similar resources at the root configuration.lets say I have a module
machine
in{working_dir}/machine
:Setup
main.tf
:./machine/main.tf
:Steps to Reproduce Issue
libvirt
provider.terraform init
provider
block from./machines/main.tf
allows module to work but no longer runs with correct context ofqemu:///session
, and defaults toqemu:///system
.terraform
block from./machines/main.tf
causes module not correctly resolve.Additional information:
Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? No
Have you tried to reproduce the issue without them enabled? n/a
The text was updated successfully, but these errors were encountered: