Added outputs for IPs.
- Made sure node-memory ad node-vcpus is passed down to module. - Fixed get-vm-ips.sh after move to module.
This commit is contained in:
+7
-5
@@ -3,15 +3,17 @@
|
|||||||
# Use eval $(./get-vm-ips.sh) to set env vars for ips.
|
# Use eval $(./get-vm-ips.sh) to set env vars for ips.
|
||||||
|
|
||||||
terraform refresh > /dev/null
|
terraform refresh > /dev/null
|
||||||
IPS_JSON="$(terraform show -json | jq '.values.root_module.resources[] | select(.type == "libvirt_domain") | {name: .values.name, ip: .values.network_interface[0].addresses[0]}')"
|
|
||||||
|
IPS_JSON="$(terraform show -json | jq '.values.outputs')"
|
||||||
|
|
||||||
echo $IPS_JSON | \
|
echo $IPS_JSON | \
|
||||||
jq 'select(.name | contains("master")) | .ip' | \
|
jq '."master-ips".value[]' | \
|
||||||
xargs -I% echo export MASTER=%
|
nl -v 0 | \
|
||||||
|
awk '{print "export MASTER" $1 "=" $2}' | \
|
||||||
|
sed 's/"//g'
|
||||||
|
|
||||||
echo $IPS_JSON | \
|
echo $IPS_JSON | \
|
||||||
jq 'select(.name | contains("worker")) | .ip' | \
|
jq '."worker-ips".value[]' | \
|
||||||
nl -v 0 | \
|
nl -v 0 | \
|
||||||
awk '{print "export WORKER" $1 "=" $2}' | \
|
awk '{print "export WORKER" $1 "=" $2}' | \
|
||||||
sed 's/"//g'
|
sed 's/"//g'
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ module "master-nodes" {
|
|||||||
pool-name = libvirt_pool.images.name
|
pool-name = libvirt_pool.images.name
|
||||||
name-prefix = "${var.vm-name-prefix}-master"
|
name-prefix = "${var.vm-name-prefix}-master"
|
||||||
num-nodes = var.master-nodes
|
num-nodes = var.master-nodes
|
||||||
|
node-memory = var.node-memory
|
||||||
|
node-vcpus = var.node-vcpus
|
||||||
base-image = var.ubuntu-image
|
base-image = var.ubuntu-image
|
||||||
root-admin-passwd = var.root-admin-passwd
|
root-admin-passwd = var.root-admin-passwd
|
||||||
root-admin-pub-key = var.root-admin-pub-key
|
root-admin-pub-key = var.root-admin-pub-key
|
||||||
@@ -28,6 +30,8 @@ module "worker-nodes" {
|
|||||||
pool-name = libvirt_pool.images.name
|
pool-name = libvirt_pool.images.name
|
||||||
name-prefix = "${var.vm-name-prefix}-worker"
|
name-prefix = "${var.vm-name-prefix}-worker"
|
||||||
num-nodes = var.worker-nodes
|
num-nodes = var.worker-nodes
|
||||||
|
node-memory = var.node-memory
|
||||||
|
node-vcpus = var.node-vcpus
|
||||||
base-image = var.ubuntu-image
|
base-image = var.ubuntu-image
|
||||||
root-admin-passwd = var.root-admin-passwd
|
root-admin-passwd = var.root-admin-passwd
|
||||||
root-admin-pub-key = var.root-admin-pub-key
|
root-admin-pub-key = var.root-admin-pub-key
|
||||||
@@ -39,3 +43,11 @@ resource "libvirt_pool" "images" {
|
|||||||
type = "dir"
|
type = "dir"
|
||||||
path = var.disk-image-dir
|
path = var.disk-image-dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "master-ips" {
|
||||||
|
value = module.master-nodes.ips
|
||||||
|
}
|
||||||
|
|
||||||
|
output "worker-ips" {
|
||||||
|
value = module.worker-nodes.ips
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ resource "libvirt_domain" "nodes" {
|
|||||||
network_interface {
|
network_interface {
|
||||||
network_name = "default"
|
network_name = "default"
|
||||||
hostname = "${var.name-prefix}-${count.index}"
|
hostname = "${var.name-prefix}-${count.index}"
|
||||||
|
wait_for_lease = true
|
||||||
}
|
}
|
||||||
|
|
||||||
# IMPORTANT: this is a known bug on cloud images, since they expect a console
|
# IMPORTANT: this is a known bug on cloud images, since they expect a console
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
output "ips" {
|
||||||
|
value = libvirt_domain.nodes.*.network_interface.0.addresses.0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user