Skip to content

Commit 065ea86

Browse files
committed
chore: improve README with domain IP information
1 parent da5a4ad commit 065ea86

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,62 @@ See the [examples](./examples) directory for more usage examples.
303303

304304
## Migration from Legacy Provider (v0.8.x)
305305

306+
### Getting Domain IP Addresses
307+
308+
The legacy provider exposed IP addresses directly on the domain resource via `network_interface.*.addresses`. The new provider uses a separate data source for querying IP addresses:
309+
310+
**Legacy provider (v0.8.x):**
311+
```hcl
312+
resource "libvirt_domain" "example" {
313+
# ... domain config ...
314+
}
315+
316+
output "ip" {
317+
value = libvirt_domain.example.network_interface[0].addresses[0]
318+
}
319+
```
320+
321+
**New provider (v0.9+):**
322+
```hcl
323+
resource "libvirt_domain" "example" {
324+
# ... domain config ...
325+
}
326+
327+
data "libvirt_domain_interface_addresses" "example" {
328+
domain = libvirt_domain.example.id
329+
source = "lease" # or "agent" or "any"
330+
}
331+
332+
output "ip" {
333+
value = data.libvirt_domain_interface_addresses.example.interfaces[0].addrs[0].addr
334+
}
335+
```
336+
337+
Alternatively, use the `wait_for_ip` property on the domain's interface configuration to ensure the domain has an IP before creation completes:
338+
339+
```hcl
340+
resource "libvirt_domain" "example" {
341+
name = "example-vm"
342+
memory = 512
343+
vcpu = 1
344+
345+
devices = {
346+
interfaces = [
347+
{
348+
type = "network"
349+
source = {
350+
network = "default"
351+
}
352+
wait_for_ip = {
353+
timeout = 300 # seconds
354+
source = "lease"
355+
}
356+
}
357+
]
358+
}
359+
}
360+
```
361+
306362
### Volume Source URLs
307363

308364
If you're migrating from the legacy provider and used the `source` attribute on volumes to download cloud images, note that this feature is now available via the `create.content.url` block:

0 commit comments

Comments
 (0)