From ba02ec619c4961932bd392dc42827b08fedfaeb5 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Mon, 24 Oct 2022 15:37:23 +0530 Subject: [PATCH] feat: print IP address of provisioned VMs --- sandbox/terraform/libvirt/ubuntu/ubuntu-example.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sandbox/terraform/libvirt/ubuntu/ubuntu-example.tf b/sandbox/terraform/libvirt/ubuntu/ubuntu-example.tf index 7552004..a53bc81 100644 --- a/sandbox/terraform/libvirt/ubuntu/ubuntu-example.tf +++ b/sandbox/terraform/libvirt/ubuntu/ubuntu-example.tf @@ -66,6 +66,7 @@ resource "libvirt_domain" "domain-ubuntu" { network_interface { network_name = "default" + wait_for_lease = true } # IMPORTANT: this is a known bug on cloud images, since they expect a console @@ -104,6 +105,7 @@ resource "libvirt_domain" "domain-debian-ansible-playground" { network_interface { network_name = "default" + wait_for_lease = true } # IMPORTANT: this is a known bug on cloud images, since they expect a console @@ -135,3 +137,11 @@ resource "libvirt_domain" "domain-debian-ansible-playground" { # IPs: use wait_for_lease true or after creation use terraform refresh and terraform show for the ips of domain + +output "ubuntu_ip" { + value = length(libvirt_domain.domain-ubuntu.network_interface[0].addresses) > 0 ? libvirt_domain.domain-ubuntu.network_interface[0].addresses[0] : "" +} + +output "debian_ip" { + value = length(libvirt_domain.domain-debian-ansible-playground.network_interface[0].addresses) > 0 ? libvirt_domain.domain-debian-ansible-playground.network_interface[0].addresses[0] : "" +}