terraform-provider-libvirt: unable to create a static ipv6 routed domain
Version Reports:
Distro version of host:
CentOS Linux release 7.5.1804 (Core)
Terraform Version Report
Terraform v0.11.8
Libvirt version
3.9.0
terraform-provider-libvirt plugin version (git-hash)
f104fad4
Description of Issue/Question
Setup
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_network" "public"{
name = "public"
mode = "route"
bridge = "br-public"
addresses = ["{{ ipv6_network }}"]
dhcp {
enabled = "false"
}
autostart = "true"
}
resource "libvirt_domain" "tf_test" {
# init
name = "tf_test"
metadata = "tf_test"
vcpu = 2
memory = 512
running = false
autostart = false
# network
network_interface {
network_id = "${libvirt_network.public.id}"
addresses = ["{{ ipv6_address }}"]
# wait_for_lease = true
}
}
Steps to Reproduce Issue
terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ libvirt_domain.tf_test
id: <computed>
arch: <computed>
autostart: "false"
emulator: <computed>
machine: <computed>
memory: "512"
metadata: "tf_test"
name: "tf_test"
network_interface.#: "1"
network_interface.0.addresses.#: "1"
network_interface.0.addresses.0: "{{ ipv6_address }}"
network_interface.0.hostname: <computed>
network_interface.0.mac: <computed>
network_interface.0.network_id: "${libvirt_network.public.id}"
network_interface.0.network_name: <computed>
qemu_agent: "false"
running: "false"
vcpu: "2"
+ libvirt_network.public
id: <computed>
addresses.#: "1"
addresses.0: "{{ ipv6_network }}"
autostart: "true"
bridge: "br-public"
dhcp.#: "1"
dhcp.0.enabled: "false"
mode: "route"
name: "public"
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
libvirt_network.public: Creating...
addresses.#: "" => "1"
addresses.0: "" => "{{ ipv6_network }}"
autostart: "" => "true"
bridge: "" => "br-public"
dhcp.#: "" => "1"
dhcp.0.enabled: "" => "false"
mode: "" => "route"
name: "" => "public"
libvirt_network.public: Creation complete after 5s (ID: 3cc28126-de07-4cbc-b4ff-cd62c234cc38)
libvirt_domain.tf_test: Creating...
arch: "" => "<computed>"
autostart: "" => "false"
emulator: "" => "<computed>"
machine: "" => "<computed>"
memory: "" => "512"
metadata: "" => "tf_test"
name: "" => "tf_test"
network_interface.#: "" => "1"
network_interface.0.addresses.#: "" => "1"
network_interface.0.addresses.0: "" => "{{ ipv6_address }}"
network_interface.0.hostname: "" => "<computed>"
network_interface.0.mac: "" => "<computed>"
network_interface.0.network_id: "" => "3cc28126-de07-4cbc-b4ff-cd62c234cc38"
network_interface.0.network_name: "" => "<computed>"
qemu_agent: "" => "false"
running: "" => "false"
vcpu: "" => "2"
Error: Error applying plan:
1 error(s) occurred:
* libvirt_domain.tf_test: 1 error(s) occurred:
* libvirt_domain.tf_test: virError(Code=27, Domain=19, Message='XML error: Invalid to specify MAC address '76:92:e8:5a:a4:9b' in network 'public' IPv6 static host definition')
If I try to uncomment wait_for_lease = true the domain is correctly created, terraform doesn’t end because dchp enabled is false, so no lease will be assigned to the domain
If I choose a custom (not computed) MAC address I get the same error. Maybe I’m missing some obvious.
I attach a trace level terraform log: tf_test_static_ipv6_routed.log
Feel free to ask any additional information and keep up the good work on this nice project.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 4
- Comments: 15 (1 by maintainers)
Commits related to this issue
- Remove mac generation in networkXml libvirt will autogenerate a proper one. Fix #396 — committed to MalloZup/terraform-provider-libvirt by MalloZup 6 years ago
- Remove mac generation in networkXml libvirt will autogenerate a proper one. Fix #396 — committed to MalloZup/terraform-provider-libvirt by MalloZup 6 years ago
- Remove mac generation in networkXml libvirt will autogenerate a proper one. Fix #396 — committed to MalloZup/terraform-provider-libvirt by MalloZup 6 years ago
- Update Terraform SDK to 1.13.1 See https://raw.githubusercontent.com/hashicorp/terraform-plugin-sdk/v1-maint/CHANGELOG.md BUG FIXES: * Remove deprecation for `d.Partial` ([#463](https://github.com/... — committed to dirkmueller/terraform-provider-libvirt by dirkmueller 4 years ago
- Update Terraform SDK to 1.13.1 See https://raw.githubusercontent.com/hashicorp/terraform-plugin-sdk/v1-maint/CHANGELOG.md BUG FIXES: * Remove deprecation for `d.Partial` ([#463](https://github.com/... — committed to dirkmueller/terraform-provider-libvirt by dirkmueller 4 years ago
- Remove mac generation in networkXml libvirt will autogenerate a proper one. Fix #396 — committed to cfergeau/terraform-provider-libvirt by MalloZup 6 years ago
- Remove mac generation in networkXml libvirt will autogenerate a proper one. Fix #396 — committed to cfergeau/terraform-provider-libvirt by MalloZup 6 years ago
Ok, I think i’ve figured out what the problem is.
If an ipv6 network / addressing scheme is used, libvirt checks if in the input xml for network manipulation there is the field
macand if it’s present gives the error:Invalid to specify MAC address 'XX:XX:XX:XX:XX:XX' in network 'public' IPv6 static host definition'This because for the ipv6 the use of mac address (in a dchp context, like used by libvirt) is deprecated and replaced by DHCP Unique Identifier (DUID).
The provider doesn’t seem to make difference between ipv4 and ipv6 and it always generates a mac address.
Then the generated mac address in the
libvirt/utils_libvirt_gois used to create the xml which is passed to libvirt-go, processed by libvirt-go and at the end arrives at libvirt where the error pops up.Thank you. I’ll do some investigation on libvirt too,I’ll try to reproduce the same issue on virsh and I’ll let you know.
@MalloZup This one seems to be waiting on you to finish your PR. 😃 BTW, please add some more info to your git commit messages themselves. One doesn’t always have internet (think flights) access and details in git history are your only hope then to figure how why some change was introduced. 😃
Ok, using your feature branch
nomacI’m correctly able to create ipv6 routed domain.This:
now works withour error.