Closed PDiogoVS closed 1 year ago
Hi @PDiogoVS,
thanks for your report! I updated the examples and documentation for the datasource wait-for-ip
. The example here shows how to access the ipv4. Does this answer your question?
close, but not responding :)
with your example i have the following output:
test = tolist([
toset([
"192.168.101.212",
]),
])
but when i try to use data.ovirt_wait_for_ip.test["test"].interfaces.*.ipv4_addresses
to do a connection like:
resource "null_resource" "example1" {
connection {
host = data.ovirt_wait_for_ip.test["test"].interfaces.*.ipv4_addresses
user = "root"
password = var.ovirt_password
agent = false
timeout = "3m"
}
provisioner "remote-exec" {
# Leave this here so we know when to start with Ansible local-exec
inline = [
"echo 'Cool, we are ready for provisioning'",
"touch /tmp/terraform_hello.demo"
]
}
depends_on = [data.ovirt_wait_for_ip.test]
}
I have following error:
Error: Incorrect attribute value type
│
│ on main.tf line 80, in resource "null_resource" "example1":
│ 80: host = data.ovirt_wait_for_ip.test["test"].interfaces.*.ipv4_addresses
│ ├────────────────
│ │ data.ovirt_wait_for_ip.test["test"].interfaces is set of object with 1 element
│
│ Inappropriate value for attribute "host": string required.
i think output you send it's a list or map you know how i can use only the first item?
Please refer to this https://github.com/oVirt/terraform-provider-ovirt/issues/474#issuecomment-1235743427
As stated there:
The field
ipv4_addresses
on theovirt_wait_for_ip
datasource is a nested set of strings, which is quite cumbersome to deal with in terraform.
Does the linked comment solve your problem?
Yes!!! Thank you
First, let me report that I try to use
ovirt_wait_for_ip
as described in the documentation, but it's not working.Documentation: ... // Expect an IP address to be reported by the VM resource "ovirt_wait_for_ip" "test" { vm_id = ovirt_vm_start.test.vm_id ...
Correction ... // Expect an IP address to be reported by the VM data "ovirt_wait_for_ip" "test" { vm_id = ovirt_vm_start.test.vm_id ...
But my problem and request for help is... I try to use this data to get an IP of a vm and make a connection on another resource, so my data is: ...
...
how can i use or put this data in a variable like this:
ip="192.168.101.214"
my next attempt is:
with code: